function importar_ctw($db = "ctw10005.dbf", $id = "2007")
{
    //elimina la anterior
    mysql_unbuffered_query("TRUNCATE compacw_importados");
    $pathdbase = CTW_PATH . "/" . $db;
    //$db = dbase_open($ipdbase . $dirdbase . $nombredb . $db, 0);
    $rs = dbase_open($pathdbase, 2);
    //echo $pathdbase;
    $num_rows = dbase_numrecords($rs);
    //$o_num_rows = dbase_numrecords ($rs);
    //$num_rows = 100000;				//Eliminar la Consulta a 50000
    for ($i = 1; $i <= $num_rows; $i++) {
        $field = dbase_get_record_with_names($rs, $i);
        if (trim($field["EJE"]) == $id and trim($field["TIPO"]) == 1) {
            //
            $values_sql = " ('" . $field["CUENTA"] . "', " . $field["IMP1"] . ") ";
            $sql_ex = "INSERT INTO compacw_importados(cuenta, saldo) VALUES " . $values_sql;
            mysql_unbuffered_query($sql_ex);
            //
        }
    }
    //
    //dbase_pack($rs);
    dbase_close($rs);
    echo "<p>DATOS IMPORTADOS:  " . date("H:i:s") . " HRS </p>";
}
Example #2
0
 public function ListRead()
 {
     $count = dbase_numrecords($this->_dBase);
     for ($i = 1; $i <= $count; $i++) {
         $row = dbase_get_record_with_names($this->_dBase, $i);
     }
 }
 public function postDailySales()
 {
     $dbf_file = $this->extracted_path . DS . 'CSH_AUDT.DBF';
     if (file_exists($dbf_file)) {
         $db = dbase_open($dbf_file, 0);
         $header = dbase_get_header_info($db);
         $record_numbers = dbase_numrecords($db);
         $last_ds = $this->ds->lastRecord();
         $update = 0;
         for ($i = 1; $i <= $record_numbers; $i++) {
             $row = dbase_get_record_with_names($db, $i);
             $vfpdate = vfpdate_to_carbon(trim($row['TRANDATE']));
             if (is_null($last_ds)) {
                 $attrs = ['date' => $vfpdate->format('Y-m-d'), 'branchid' => session('user.branchid'), 'managerid' => session('user.id'), 'sales' => $row['CSH_SALE'] + $row['CHG_SALE'], 'tips' => $row['TIP'], 'custcount' => $row['CUST_CNT'], 'empcount' => $row['CREW_KIT'] + $row['CREW_DIN']];
                 if ($this->ds->firstOrNew($attrs, ['date', 'branchid'])) {
                 }
                 $update++;
             } else {
                 if ($last_ds->date->lte($vfpdate)) {
                     $attrs = ['date' => $vfpdate->format('Y-m-d'), 'branchid' => session('user.branchid'), 'managerid' => session('user.id'), 'sales' => $row['CSH_SALE'] + $row['CHG_SALE'], 'tips' => $row['TIP'], 'custcount' => $row['CUST_CNT'], 'empcount' => $row['CREW_KIT'] + $row['CREW_DIN']];
                     if ($this->ds->firstOrNew($attrs, ['date', 'branchid'])) {
                     }
                     $update++;
                 }
             }
         }
         dbase_close($db);
         return count($update > 0) ? true : false;
     }
     return false;
 }
Example #4
0
 function get_encabezado_llenado()
 {
     if ($this->dbf) {
         $numero_registros = dbase_numrecords($this->dbf);
         $this->tabla_sql_data = "INSERT INTO `" . $this->nombre_tabla . "` (\n" . $this->get_campos_str();
         for ($i = 1; $i <= $numero_registros; $i++) {
             $fila = dbase_get_record_with_names($this->dbf, $i);
             $control = 0;
             $this->tabla_sql_data .= "(";
             foreach ($fila as $key => $value) {
                 if ($control < count($fila) - 1) {
                     if ($this->campos[$control]['type'] === 'number') {
                         $this->tabla_sql_data .= $fila[$key];
                     } else {
                         $this->tabla_sql_data .= "'" . $fila[$key] . "'";
                     }
                     if ($control != count($fila) - 2) {
                         $this->tabla_sql_data .= ",";
                     } else {
                         $this->tabla_sql_data .= "),";
                     }
                 }
                 $control++;
             }
         }
         $cad = $this->tabla_sql_data;
         $this->tabla_sql_data = substr($cad, 0, -1);
         $this->tabla_sql_data .= ";";
     }
     //Fin IF Principal
 }
 /**
  * Обновляет справочник банков, используя указанный файл или файл из папки data.
  *
  * Необходимо расширение dbase. Установить расширение dbase можно так: sudo pecl install dbase
  *
  * @param null $file
  * @return int
  */
 public function actionIndex($file = null)
 {
     if (!extension_loaded('dbase')) {
         $this->stdout("Для работы скрипта обновления необходимо установить расширение dbase\n", Console::FG_RED);
         return 1;
     }
     if ($file === null) {
         $file = Yii::getAlias(dirname(__FILE__) . '/../data/bnkseek.dbf');
     } else {
         $file = Yii::getAlias($file);
     }
     if (!file_exists($file)) {
         $this->stdout("Файл {$file} не найден!\n", Console::FG_RED);
         return 1;
     }
     if ($this->confirm("Обновить справочник банков России, используя файл {$file}?")) {
         $this->stdout('Выполняю обновление...' . "\n");
         $db = dbase_open($file, 0);
         if (!$db) {
             $this->stdout("Не удалось открыть файл как базу данный dbase!\n", Console::FG_RED);
             return 1;
         }
         $current_db_records_count = Bank::find()->count();
         $data_records_count = dbase_numrecords($db);
         $data_updated = false;
         $this->stdout("Количество банков в текущем справочнике - {$current_db_records_count}.\n");
         $this->stdout("Количество банков в файле - {$data_records_count}.\n");
         for ($i = 1; $i <= $data_records_count; $i++) {
             $rec = dbase_get_record_with_names($db, $i);
             /** @var Bank $model */
             $model = Yii::createObject(['class' => Bank::className(), 'bik' => $rec["NEWNUM"], 'okpo' => $rec["OKPO"], 'full_name' => iconv('CP866', 'utf-8', $rec["NAMEP"]), 'short_name' => iconv('CP866', 'utf-8', $rec["NAMEN"]), 'ks' => $rec["KSNP"], 'city' => iconv('CP866', 'utf-8', $rec["NNP"]), 'zip' => (int) $rec["IND"], 'address' => iconv('CP866', 'utf-8', $rec["ADR"]), 'tel' => iconv('CP866', 'utf-8', $rec["TELEF"])]);
             foreach ($model->getAttributes() as $key => $value) {
                 $model->{$key} = trim($value);
             }
             /** @var Bank $exist */
             $exist = Bank::findOne($model->bik);
             if (!$exist) {
                 $this->stdout("Добавлен новый банк: {$model->bik} {$model->short_name}\n");
                 $data_updated = true;
                 $model->save(false);
             } else {
                 if ($exist->getAttributes() != $model->getAttributes()) {
                     $exist->setAttributes($model->getAttributes());
                     $this->stdout("Обновлены данные банка: {$exist->bik} {$exist->short_name}\n");
                     $data_updated = true;
                     $exist->save(false);
                 }
             }
         }
         dbase_close($db);
         if ($data_updated) {
             $this->stdout('Справочник банков успешно обновлен!' . "\n", Console::FG_GREEN);
         } else {
             $this->stdout('В справочник банков не было внесено изменений.' . "\n", Console::FG_GREEN);
         }
     }
     return 0;
 }
Example #6
0
 public function actionImportDbf($filename, $region = false)
 {
     $db = @dbase_open($filename, 0);
     if (!$db) {
         $this->stderr("Не удалось открыть DBF файл: '{$filename}'\n");
         return 1;
     }
     $classMap = ['/^.*DADDROBJ\\.DBF$/' => FiasDaddrobj::className(), '/^.*ADDROBJ\\.DBF$/' => FiasAddrobj::className(), '/^.*LANDMARK\\.DBF$/' => FiasLandmark::className(), '/^.*DHOUSE\\.DBF$/' => FiasDhouse::className(), '/^.*HOUSE\\d\\d\\.DBF$/' => FiasHouse::className(), '/^.*DHOUSINT\\.DBF$/' => FiasDhousint::className(), '/^.*HOUSEINT\\.DBF$/' => FiasHouseint::className(), '/^.*DLANDMRK\\.DBF$/' => FiasDlandmrk::className(), '/^.*DNORDOC\\.DBF$/' => FiasDnordoc::className(), '/^.*NORDOC\\d\\d\\.DBF$/' => FiasNordoc::className(), '/^.*ESTSTAT\\.DBF$/' => FiasDhousint::className(), '/^.*ACTSTAT\\.DBF$/' => FiasActstat::className(), '/^.*CENTERST\\.DBF$/' => FiasCenterst::className(), '/^.*ESTSTAT\\.DBF$/' => FiasEststat::className(), '/^.*HSTSTAT\\.DBF$/' => FiasHststat::className(), '/^.*OPERSTAT\\.DBF$/' => FiasOperstat::className(), '/^.*INTVSTAT\\.DBF$/' => FiasIntvstat::className(), '/^.*STRSTAT\\.DBF$/' => FiasStrstat::className(), '/^.*CURENTST\\.DBF$/' => FiasCurentst::className(), '/^.*SOCRBASE\\.DBF$/' => FiasSocrbase::className()];
     $modelClass = false;
     foreach ($classMap as $pattern => $className) {
         if (preg_match($pattern, $filename)) {
             $modelClass = $className;
             break;
         }
     }
     if ($modelClass === false) {
         $this->stderr("Не поддерживаемый DBF файл: '{$filename}'\n");
         return 1;
     }
     $rowsCount = dbase_numrecords($db);
     $this->stdout("Записей в DBF файле '{$filename}' : {$rowsCount}\n");
     $j = 0;
     for ($i = 1; $i <= $rowsCount; $i++) {
         $row = dbase_get_record_with_names($db, $i);
         if ($modelClass == FiasAddrobj::className() && $this->region && intval($row['REGIONCODE']) != intval($this->region)) {
             continue;
         }
         if ($j == 0) {
             $transaction = Yii::$app->db->beginTransaction();
         }
         $model = new $modelClass();
         foreach ($row as $key => $value) {
             if ($key == 'deleted') {
                 continue;
             }
             $key = strtolower($key);
             $model->{$key} = trim(mb_convert_encoding($value, 'UTF-8', 'CP866'));
         }
         $model->save();
         $j++;
         if ($j == 1000) {
             $transaction->commit();
             $j = 0;
             $this->stdout("Обработано {$i} из {$rowsCount} записей\n");
         }
     }
     if ($j != 0) {
         $transaction->commit();
     }
     return 0;
 }
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<info>Started at ' . date('H:i:s') . '</info>');
        $em = $this->em = $this->getEntityManager('default');

        $this->truncate();

        $db_path = __DIR__ . '/../Resources/KLADR/STREET.DBF';
        $db = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '$db_path'.");
        $record_numbers = dbase_numrecords($db);

        $batchSize = $input->getOption('batch');
        for ($i = 1; $i <= $record_numbers; $i++) {
            $row = dbase_get_record_with_names($db, $i);

            $street = new KladrStreet();
            $street->setTitle(trim(iconv('cp866', 'utf8', $row['NAME'])));

            $code = trim($row['CODE']);
            if(substr($code, -2) != '00')
                continue;

            $code = substr($code, 0, -2);
            $street->setId($code);
            $street->setParentCode(intval(str_pad(substr($code, 0, -4), 11, '0', STR_PAD_RIGHT)));

            $street->setZip(trim($row['INDEX']));
            $street->setOcatd(trim($row['OCATD']));
            $street->setSocr(trim(iconv('cp866', 'utf8', $row['SOCR'])));

            $em->persist($street);

            if (($i % $batchSize) == 0) {
                $em->flush();
                $em->clear();
                $output->writeln('<info>Inserted '. $i. ' records</info>');
            }
        }
        $em->flush();

        $output->writeln('<info>Inserted '. $i. ' records</info>');
        $output->writeln('<info>Success</info>');
        $output->writeln('<info>Deleting dead links</info>');
        $this->deleteNotLinkedElements();
        $output->writeln('<info>Assigning parents</info>');
        $this->updateParents();
        $output->writeln('<info>Success</info>');
    }
Example #8
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';
     }
 }
Example #9
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;
        }
    }
}
<?php

error_reporting('-1');
$db = dbase_open('chart.dbf', 0);
if ($db) {
    $record_numbers = dbase_numrecords($db);
    for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($db, $i);
        foreach ($row as $key => $value) {
            echo $key . ': ' . $value . '<br/>';
        }
        //      echo print_r($row,true);
        //if ($row['ismember'] == 1) {
        //   echo "Member #$i: " . trim($row['name']) . "\n";
        //}
    }
}
?>

Example #11
0
 public function getRecord($geometry_format = self::GEOMETRY_ARRAY)
 {
     if (ftell($this->shp) >= $this->file_size) {
         return false;
     }
     $record_number = $this->ReadData('N');
     $content_length = $this->ReadData('N');
     $shape_type = $this->ReadData('V');
     if ($shape_type != 0 && $shape_type != $this->shape_type) {
         $this->Error('WRONG_RECORD_TYPE', $shape_type);
     }
     switch ($shape_type) {
         case 0:
             $shp = null;
             break;
         case 1:
             $shp = $this->ReadPoint();
             break;
         case 8:
             $shp = $this->ReadMultiPoint();
             break;
         case 3:
             $shp = $this->ReadPolyLine();
             break;
         case 5:
             $shp = $this->ReadPolygon();
             break;
     }
     if ($geometry_format == self::GEOMETRY_WKT) {
         $shp = $this->WKT($shp);
     }
     return array('shp' => $shp, 'dbf' => dbase_get_record_with_names($this->dbf, $record_number));
 }
Example #12
0
 private function _fetchDBFInformation()
 {
     $this->_openDBFFile();
     if ($this->dbf) {
         //En este punto salta un error si el registro 0 está vacio.
         //Ignoramos los errores, ja que aún así todo funciona perfecto.
         $this->dbf_data = dbase_get_record_with_names($this->dbf, $this->record_number);
     } else {
         $this->setError(sprintf(self::INCORRECT_DBF_FILE, $this->file_name));
     }
     $this->_closeDBFFile();
 }
Example #13
0
 public function getRecord($record_num)
 {
     $record = dbase_get_record_with_names($this->_fp, $record_num);
     return $record;
 }
Example #14
0
 function GetDBFRecByName($i)
 {
     $ret = dbase_get_record_with_names($this->DBFCon, $i) or die("Gagal Mengambil Data");
     return $ret;
 }
Example #15
0
 function baca_dbf()
 {
     $filez = './uploads/urut.DBF';
     $dbf = dbase_open($filez, 0);
     $column_info = dbase_get_header_info($dbf);
     $loop = dbase_numrecords($dbf);
     for ($i = 1; $i <= $loop; $i++) {
         $row = dbase_get_record_with_names($dbf, $i);
         $data = array("nik" => $row['ID'], "mchID" => $row['IDABS']);
         $this->db->insert("mchID", $data);
         //echo $row['ID']."/".$row['IDABS']."<br>";
     }
     die;
 }
Example #16
0
 function fetchInto($res, &$row, $fetchmode, $rownum = null)
 {
     if ($rownum === null) {
         $rownum = $this->res_row[$res]++;
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $row = @dbase_get_record_with_names($this->connection, $rownum);
     } else {
         $row = @dbase_get_record($this->connection, $rownum);
     }
     if (!$row) {
         return null;
     }
     return DB_OK;
 }
Example #17
0
 function _cargadbf($fdbf, $fecha)
 {
     $ff = substr($fecha, 0, 6);
     $error = 0;
     $ptabla['viepag'] = 'hs' . $ff;
     $ptabla['vieite'] = 'hi' . $ff;
     $ptabla['viefac'] = 'hf' . $ff;
     $tabla = '';
     foreach ($ptabla as $ttabla => $ht) {
         if (strripos($fdbf, $ht) !== false) {
             $tabla = $ttabla;
             break;
         }
     }
     if (!empty($tabla)) {
         $db = dbase_open($fdbf, 0);
         $cc = $error = 0;
         if ($db) {
             $cajero = '';
             $record_numbers = dbase_numrecords($db);
             for ($i = 1; $i <= $record_numbers; $i++) {
                 $row = dbase_get_record_with_names($db, $i);
                 if ($row['FECHA'] == $fecha) {
                     $dbfecha = $this->db->escape($fecha);
                     if ($cc == 0) {
                         $mSQL = "DELETE FROM {$tabla} WHERE fecha={$dbfecha} AND caja=" . $this->db->escape(trim($row['CAJA']));
                         $ban = $this->db->simple_query($mSQL);
                         if (!$ban) {
                             memowrite($mSQL, 'cargahisto');
                             $error++;
                         }
                     }
                     $data = array();
                     if ($tabla == 'vieite') {
                         if (empty($cajero)) {
                             $cajero = $this->cajero;
                         }
                         $data['numero'] = trim($row['NUMERO']);
                         $data['fecha'] = $row['FECHA'];
                         $data['codigo'] = trim($row['CODIGO']);
                         $data['precio'] = $row['PRECIO'];
                         $data['monto'] = $row['MONTO'];
                         $data['cantidad'] = $row['CANTIDAD'];
                         $data['impuesto'] = $row['IMPUESTO'];
                         $data['costo'] = $row['COSTO'];
                         $data['almacen'] = '0002';
                         $data['cajero'] = $cajero;
                         $data['caja'] = trim($row['CAJA']);
                         $data['referen'] = trim($row['REFERAN']);
                     } elseif ($tabla == 'viefac') {
                         $data['numero'] = trim($row['NUMERO']);
                         $data['tipo'] = trim($row['TIPO']);
                         $data['fecha'] = $row['FECHA'];
                         $data['cajero'] = trim($row['CAJERO']);
                         $data['caja'] = trim($row['CAJA']);
                         $data['cliente'] = trim($row['CLIENTE']);
                         $data['nombres'] = trim($row['NOMBRES']);
                         $data['apellidos'] = trim($row['APELLIDOS']);
                         $data['impuesto'] = $row['IMPUESTO'];
                         $data['gtotal'] = $row['GTOTAL'];
                         $data['hora'] = $row['HORA'];
                         $data['cuadre'] = '';
                         $this->cajero = trim($row['CAJERO']);
                     } else {
                         if ($row['F_FACTURA'] != $row['FECHA']) {
                             continue;
                         }
                         if (empty($cajero)) {
                             $cajero = $this->cajero;
                         }
                         $data['tipo_doc'] = trim($row['TIPO_DOC']);
                         $data['numero'] = $row['NUMERO'];
                         $data['tipo'] = trim($row['TIPO']);
                         $data['monto'] = $row['MONTO'];
                         $data['num_ref'] = trim($row['NUM_REF']);
                         $data['clave'] = trim($row['CLAVE']);
                         $data['fecha'] = $row['FECHA'];
                         $data['banco'] = trim($row['BANCO']);
                         $data['f_factura'] = $row['F_FACTURA'];
                         $data['cajero'] = $cajero;
                         $data['caja'] = trim($row['CAJA']);
                     }
                     $mSQL = $this->db->insert_string($tabla, $data);
                     $ban = $this->db->simple_query($mSQL);
                     if (!$ban) {
                         memowrite($mSQL, 'cargahisto');
                         $error++;
                     }
                     $cc++;
                 }
             }
         }
     }
 }
Example #18
0
             $i++;
         }
     }
 }
 if ($_FILES['pok']['name'] != "") {
     mysql_query("DELETE FROM d_item WHERE THANG = '" . $ta . "'");
     $filename = $_FILES['pok']['name'];
     $filedir = "dipa_files/" . $filename;
     move_uploaded_file($_FILES["pok"]["tmp_name"], $filedir);
     $data = dbase_open($filedir, 0);
     if ($data) {
         $ndata = dbase_numrecords($data);
         $i = 0;
         #THANG 	KDJENDOK 	KDSATKER 	KDDEPT 	KDUNIT 	KDPROGRAM 	KDGIAT 	KDOUTPUT 	KDLOKASI 	KDKABKOTA 10 	KDDEKON 	KDSOUTPUT 	KDKMPNEN 	KDSKMPNEN 	KDAKUN 	KDKPPN 	KDBEBAN 	KDJNSBAN 	KDCTARIK 	REGISTER 20 	CARAHITUNG 	HEADER1 	HEADER2 	KDHEADER 	NOITEM 	NMITEM 	VOL1 	SAT1 	VOL2 	SAT2 30 	VOL3 	SAT3 	VOL4 	SAT4 	VOLKEG 	SATKEG 	HARGASAT 	JUMLAH 	PAGUPHLN 	PAGURMP 40 	PAGURKP 	KDBLOKIR 	BLOKIRPHLN 	BLOKIRRMP 	BLOKIRRKP 	RPHBLOKIR 	KDCOPY 	KDABT 	KDSBU 	VOLSBK 50 	VOLRKAKL 	BLNKONTRAK 	NOKONTRAK 	TGKONTRAK 	NILKONTRAK 	JANUARI 	PEBRUARI 	MARET 	APRIL 	MEI 60 	JUNI 	JULI 	AGUSTUS 	SEPTEMBER 	OKTOBER 	NOPEMBER 	DESEMBER 	JMLTUNDA 	KDLUNCURAN 	JMLABT 70 	NOREV 	KDUBAH 	KURS 	INDEXKPJM 	KDIB
         while ($i <= $ndata) {
             $vdata = dbase_get_record_with_names($data, $i);
             $THANG = $vdata['THANG'];
             $KDJENDOK = $vdata['KDJENDOK'];
             $KDSATKER = $vdata['KDSATKER'];
             $KDDEPT = $vdata['KDDEPT'];
             $KDUNIT = $vdata['KDUNIT'];
             $KDPROGRAM = $vdata['KDPROGRAM'];
             $KDGIAT = $vdata['KDGIAT'];
             $KDOUTPUT = $vdata['KDOUTPUT'];
             $KDLOKASI = $vdata['KDLOKASI'];
             $KDKABKOTA = $vdata['KDKABKOTA'];
             $KDDEKON = $vdata['KDDEKON'];
             $KDSOUTPUT = $vdata['KDSOUTPUT'];
             $KDKMPNEN = $vdata['KDKMPNEN'];
             $KDSKMPNEN = $vdata['KDSKMPNEN'];
             $KDAKUN = $vdata['KDAKUN'];
Example #19
0
 /**
  * Fetch an associative array of the current record, then increment record index
  * @param int $exact_dbase_index if we would rather get the exact index (and also set it)
  */
 public function fetch_assoc($exact_dbase_index = null)
 {
     if (!is_null($exact_dbase_index)) {
         $this->fetch_i = $exact_dbase_index;
     }
     if ($this->fetch_i > $this->numrecords) {
         return null;
     }
     $row = dbase_get_record_with_names($this->db, $this->fetch_i);
     $this->fetch_i++;
     if ($this->use_trim) {
         foreach ($row as &$val) {
             $val = trim($val);
         }
     }
     return $row;
 }
Example #20
0
 private function _fetchDBFInformation()
 {
     $this->_openDBFFile();
     if ($this->dbf) {
         //		  print_r($this->record_number);
         if ($this->record_number) {
             $this->dbf_data = dbase_get_record_with_names($this->dbf, $this->record_number);
         }
         //else
         //	Yii::log(print_r($this->dbf_data, true), CLogger::LEVEL_INFO, 'fetchERROR');
     } else {
         $this->setError(sprintf(INCORRECT_DBF_FILE, $this->file_name));
     }
     $this->_closeDBFFile();
 }
Example #21
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';
     }
 }
Example #22
0
 /**
 * TODO create an AJAX call to give details of what will be done before it is done:
 * ie how many will be created, how many will be updated.
 * /
   public function upload_shp_check() {
   }
 
   /**
 * Controller action that performs the import of data in an uploaded Shapefile.
 * TODO Sort out how large geometries are displayed in the locations indicia page, and also other non
 * WGS84/OSGB srids.
 * TODO Add identification of record by external code as alternative to name.
 */
 public function upload_shp2()
 {
     $zipTempFile = $_POST['uploaded_zip'];
     $basefile = $_POST['extracted_basefile'];
     // at this point do I need to extract the zipfile again? will assume at the moment that it is
     // already extracted: TODO make sure the extracted files still exist
     ini_set('auto_detect_line_endings', 1);
     $view = new View('location/upload_shp2');
     $view->update = array();
     $view->create = array();
     $view->location_id = array();
     // create the file pointer, plus one for errors
     $count = 0;
     $this->template->title = "Confirm Shapefile upload for " . $this->pagetitle;
     $dbasedb = dbase_open($basefile . '.dbf', 0);
     if (!array_key_exists('name', $_POST)) {
         $this->setError('Upload problem', 'Name column in .dbf file must be specified.');
         return;
     }
     if (array_key_exists('use_parent', $_POST) && !array_key_exists('parent', $_POST)) {
         $this->setError('Upload problem', 'Parent column in .dbf file must be specified.');
         return;
     }
     if ($dbasedb) {
         // read some data ..
         $record_numbers = dbase_numrecords($dbasedb);
         $handle = fopen($basefile . '.shp', "rb");
         //Don't care about file header: jump direct to records.
         fseek($handle, 100, SEEK_SET);
         for ($i = 1; $i <= $record_numbers; $i++) {
             $row = dbase_get_record_with_names($dbasedb, $i);
             $location_name = $_POST['prepend'] . trim(utf8_encode($row[$_POST['name']]));
             $this->loadFromFile($handle);
             if (kohana::config('sref_notations.internal_srid') != $_POST['srid']) {
                 //convert to internal srid. First convert +/-90 to a value just off, as Google Maps doesn't cope with the poles!
                 $this->wkt = str_replace(array(' 90,', ' -90,', ' 90)', ' -90)'), array(' 89.99999999,', ' -89.99999999,', ' 89.99999999)', ' -89.99999999)'), $this->wkt);
                 $result = $this->db->query("SELECT ST_asText(ST_Transform(ST_GeomFromText('" . $this->wkt . "'," . $_POST['srid'] . ")," . kohana::config('sref_notations.internal_srid') . ")) AS wkt;")->current();
                 $this->wkt = $result->wkt;
             }
             if (array_key_exists('use_parent', $_POST)) {
                 //Ensure parent already exists and is unique  - no account of website taken...
                 $parent = trim($row[$_POST['parent']]);
                 $parentSelector = array_key_exists('use_parent_code', $_POST) ? 'code' : 'name';
                 $parent_locations = $this->findLocations(array($parentSelector => $parent));
                 if (count($parent_locations) == 0) {
                     $this->setError('Upload problem', "Could not find non deleted parent where {$parentSelector} = {$parent}");
                     return;
                 }
                 if (count($parent_locations) > 1) {
                     $this->setError('Upload problem', "Found more than one non deleted parent where {$parentSelector} = {$parent}");
                     return;
                 }
                 $parent_id = $parent_locations[0]->id;
             }
             if (isset($parent_id)) {
                 //Where there is a parent, look for existing child location with same name - no account of website taken...
                 $my_locations = ORM::factory('location')->where('name', $location_name)->where('parent_id', $parent_id)->where('deleted', 'false')->find_all();
                 if (count($my_locations) > 1) {
                     $this->setError('Upload problem', 'Found ' . count($my_locations) . ' non deleted children where name = ' . $location_name . " and parent {$parentSelector} = {$parent}");
                     return;
                 }
                 $myLocation = ORM::factory('location', array('name' => $location_name, 'parent_id' => $parent_id, 'deleted' => 'false'));
             } else {
                 $my_locations_args = array('name' => $location_name);
                 if (array_key_exists('type', $_POST)) {
                     $my_locations_args['location_type_id'] = $_POST['type'];
                 }
                 $my_locations = $this->findLocations($my_locations_args);
                 if (count($my_locations) > 1) {
                     $this->setError('Upload problem', 'Found more than one location where name = ' . $location_name);
                     return;
                 } elseif (count($my_locations) === 1) {
                     $myLocation = ORM::factory('location', $my_locations[0]->id);
                 } else {
                     $myLocation = ORM::factory('location');
                 }
             }
             if ($myLocation->loaded) {
                 // update existing record
                 if (array_key_exists('boundary', $_POST)) {
                     $myLocation->__set('boundary_geom', $this->wkt);
                     $myLocation->setCentroid(isset($_POST['use_sref_system']) && $_POST['use_sref_system'] && isset($_POST['srid']) && $_POST['srid'] != '' ? $_POST['srid'] : '4326');
                 } else {
                     $myLocation->__set('centroid_geom', $this->wkt);
                     $myLocation->__set('centroid_sref', $this->firstPoint);
                     $myLocation->__set('centroid_sref_system', $_POST['srid']);
                 }
                 $myLocation->save();
                 $description = $location_name . (isset($parent) ? ' - parent ' . $parent : '');
                 $view->update[] = $description;
                 $view->location_id[$description] = $myLocation->id;
             } else {
                 // create a new record
                 $fields = array('name' => array('value' => $location_name), 'deleted' => array('value' => 'f'), 'public' => array('value' => $_POST['website_id'] == 'all' ? 't' : 'f'));
                 if (array_key_exists('boundary', $_POST)) {
                     //centroid is calculated in Location_Model::preSubmit
                     $fields['boundary_geom'] = array('value' => $this->wkt);
                     if (isset($_POST['use_sref_system']) && $_POST['use_sref_system'] && isset($_POST['srid']) && $_POST['srid'] != '') {
                         $fields['centroid_sref_system'] = array('value' => $_POST['srid']);
                     }
                 } else {
                     $fields['centroid_geom'] = array('value' => $this->wkt);
                     $fields['centroid_sref'] = array('value' => $this->firstPoint);
                     $fields['centroid_sref_system'] = array('value' => $_POST['srid']);
                 }
                 if (array_key_exists('use_parent', $_POST)) {
                     $fields['parent_id'] = array('value' => $parent_id);
                 }
                 if (array_key_exists('code', $_POST)) {
                     $fields['code'] = array('value' => trim($row[$_POST['code']]));
                 }
                 if (array_key_exists('type', $_POST)) {
                     $fields['location_type_id'] = array('value' => $_POST['type']);
                 }
                 $save_array = array('id' => $myLocation->object_name, 'fields' => $fields, 'fkFields' => array(), 'superModels' => array());
                 if ($_POST['website_id'] != 'all') {
                     $save_array['joinsTo'] = array('website' => array($_POST['website_id']));
                 }
                 $myLocation->submission = $save_array;
                 $myLocation->submit();
                 $description = $location_name . (isset($parent) ? ' - parent ' . $parent : '');
                 $view->create[] = $description;
                 $view->location_id[$description] = $myLocation->id;
             }
         }
         fclose($handle);
         dbase_close($dbasedb);
     }
     kohana::log('debug', 'locations import done');
     $view->model = $this->model;
     $view->controllerpath = $this->controllerpath;
     $this->template->content = $view;
     $this->page_breadcrumbs[] = html::anchor($this->model->object_name, $this->pagetitle);
     $this->page_breadcrumbs[] = 'Setup SHP File upload';
 }
<?php

include_once "sisfokampus.php";
HeaderSisfoKampus("Import NIDN Dosen");
$NamaFiledbf = "MSDOS.dbf";
$nmf = "file/{$NamaFiledbf}";
$tot = 0;
if (file_exists($nmf)) {
    $conn = dbase_open($nmf, 0);
    if ($conn) {
        $dbfrec = dbase_numrecords($conn);
        if ($dbfrec) {
            for ($i = 1; $i <= $dbfrec; $i++) {
                $row = dbase_get_record_with_names($conn, $i);
                $KTP = trim($row['NOKTPMSDOS']);
                $GELAR = trim($row['GELARMSDOS']);
                $TEMPATLAHIR = trim($row['TPLHRMSDOS']);
                $JABATAN = trim($row['KDJANMSDOS']);
                $JENJANG = trim($row['KDPDAMSDOS']);
                $STATUS = trim($row['KDSTAMSDOS']);
                $NIPPNS = trim($row['NIPNSMSDOS']);
                $INDUK = trim($row['PTINDMSDOS']);
                $DosenID = trim($row['NODOS_']);
                $s = "update dosen set \r\n\t\t\t\t\t\t\t\t\tKTP = '{$KTP}', Gelar='{$GELAR}', JabatanID='{$JABATAN}', JenjangID='{$JENJANG}',\r\n\t\t\t\t\t\t\t\t\tStatusKerjaID='{$STATUS}', NIPPNS='{$NIPPNS}', HomebaseInduk='{$INDUK}', TempatLahir='{$TEMPATLAHIR}'\r\n\t\t\t\t\t\t\t\t\twhere Login = '******'";
                $r = _query($s);
                echo $tot . "\n";
                $tot++;
            }
        } else {
            die("Gagal Membuka File DBF");
        }
Example #24
0
 function fetch_object($query, $case = 0)
 {
     $this->error = "";
     //Set the errors to none
     if ($this->debug) {
         $this->debugmsg("Fetching object on " . $this->dbtype . " database....", "blue");
         $this->debugmsg($query, "purple");
     }
     switch ($this->dbtype) {
         /* Firebird Functionality */
         case "firebird":
             $query = ibase_fetch_object($query);
             break;
             /* SQLite Functionality */
         /* SQLite Functionality */
         case "sqlite":
             $query = sqlite_fetch_object($query);
             break;
             /*DBASE - this uses the record counter - currentrecord */
         /*DBASE - this uses the record counter - currentrecord */
         case "dbase":
             if ($this->currentrecord <= $this->num_rows($none)) {
                 $temp = dbase_get_record_with_names($this->dbh, $this->currentrecord);
                 $this->currentrecord++;
                 foreach ($temp as $name => $value) {
                     $name = $name;
                     $value = str_replace("'", "''", $value);
                     $query->{$name} = trim($value);
                 }
             } else {
                 $query = false;
             }
             break;
             /* MYSQL Functionality */
         /* MYSQL Functionality */
         case "mysql":
             //echo $query;
             $query = mysql_fetch_object($query);
             break;
             /* Oracle Functionality */
         /* Oracle Functionality */
         case "oracle":
             $query = oci_fetch_object($query);
             break;
             /* MSSQL Functionality */
         /* MSSQL Functionality */
         case "mssql":
             $query = mssql_fetch_object($query);
             break;
             /* PGSQL Functionality */
         /* PGSQL Functionality */
         case "pgsql":
             $query = pg_fetch_object($query);
             break;
     }
     //because of field name differences i choose to make all results uppercase as with firebird conventions as default
     //print_r ($query);
     if ($case == 0) {
         if (is_object($query)) {
             foreach ($query as $name => $value) {
                 //Clean up the underscores and other characters
                 $testname = str_replace("_", "", $name);
                 if (ctype_lower($testname)) {
                     unset($query->{$name});
                 }
                 $name = strtoupper($name);
                 $query->{$name} = $value;
             }
         }
     } else {
         if (is_object($query)) {
             foreach ($query as $name => $value) {
                 //Clean up the underscores and other characters
                 $testname = str_replace("_", "", $name);
                 if (ctype_upper($testname)) {
                     unset($query->{$name});
                 }
                 $name = strtolower($name);
                 $query->{$name} = $value;
             }
         }
     }
     if ($this->debug) {
         $this->debugmsg("Fetched object for " . $this->dbtype . " database....", "green");
         $this->debugmsg($this->pre_r($query), "purple");
     }
     return $query;
 }
Example #25
0
 //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++) {
     for ($i = 0; $i < count($en_tete); $i++) {
         if ($en_tete[$i] == $tabchamps[$k]) {
             $tabindice[] = $i;
Example #26
0
function aplod0()
{
    //$tahun = $_SESSION['tahun'];
    $Filedbf = $_FILES['nmf']['tmp_name'];
    $NamaFiledbf = $_FILES['nmf']['name'];
    $x = 0;
    $nmf = "autodebetup/{$NamaFiledbf}";
    if (move_uploaded_file($Filedbf, $nmf)) {
        if (file_exists($nmf)) {
            $conn = dbase_open($nmf, 0);
            if ($conn) {
                $dbfrec = dbase_numrecords($conn);
                if ($dbfrec) {
                    for ($i = 1; $i <= $dbfrec; $i++) {
                        $row = dbase_get_record_with_names($conn, $i);
                        $BPM = substr_replace($row['NOBPMTRINA'], '2007-', 0, 4);
                        $nobpm = GetaField('bayarmhsw', "BayarMhswID", $BPM, 'MhswID');
                        if (!empty($nobpm)) {
                            //var_dump($row['STATUTRINA']); exit;
                            $STATUS = trim($row['STATUTRINA']);
                            if ($STATUS == 'S') {
                                $x++;
                                $khsid = GetaField('khs', "TahunID = '{$row['THSMSTRINA']}' and MhswID", $row['NIMHSTRINA'], 'KHSID');
                                $_SESSION['BPT' . $x] = "{$row['NLHUTTRINA']}(30);{$row['NLDENTRINA']}(35);{$row['NLSEMTRINA']}(11);{$row['NLKOKTRINA']}(8);{$row['NLPRATRINA']}(6);{$row['NLSKSTRINA']}(5);{$row['NLSRITRINA']}(38)";
                                $_SESSION['ADUP' . $x] = "{$row['NIMHSTRINA']}~{$khsid}~{$BPM}~{$row['TAGIHTRINA']}~{$row['THSMSTRINA']}";
                            } else {
                            }
                        }
                    }
                    $_SESSION['ADUPPOS'] = 1;
                    $_SESSION['ADUPPOSX'] = $x;
                    echo "<p>File yang diupload akan diproses. Terdapat <b>{$x}</b> data yg akan diupload.</p>\r\n\t\t\t\t\t\t\t\t<p><IFRAME src='cetak/autodebet1.php?WZRD=aplod0' frameborder=0 height=300 width=300>\r\n\t\t\t\t\t\t\t\t</IFRAME></p>";
                }
            } else {
                echo ErrorMsg("Gagal Membuka file Autodebet", "File Autodebet gagal di buka, ulangi proses sekali lagi.");
            }
        } else {
            echo ErrorMsg("Proses Upload File DBF Gagal", "File gagal diupload. Coba ulangi sekali lagi.\r\n      <hr size=1>\r\n      Opsi: <a href='?mnux={$_SESSION['mnux']}'>Kembali</a>");
        }
    } else {
        $err = $_FILES['nmf']['error'][0];
        $nama = $_FILES['nmf']['name'];
        echo ErrorMsg("Gagal Upload", "File autodebet gagal diupload. File yg diupload: {$nama}. <br />\r\n    Pesan error: {$err}");
    }
}
Example #27
0
 function _loadDBFData()
 {
     $this->DBFData = @dbase_get_record_with_names($this->DBFFile, $this->recordNumber);
     unset($this->DBFData["deleted"]);
 }
Example #28
0
 public function epsbed()
 {
     $dir_dbf = "C:/DIKTI";
     $temp_db = dbase_open($dir_dbf . "/TRNLM.dbf", 0);
     $temp_isi = array();
     $x = 0;
     if ($temp_db) {
         $jml_record = dbase_numrecords($temp_db);
         for ($i = 1; $i <= $jml_record; $i++) {
             $row = dbase_get_record_with_names($temp_db, $i);
             if ($row['THSMSTRNLM'] == '20141' && $row['KDKMKTRNLM'] == 'WAT301    ') {
                 $temp_isi[] = $row['NIMHSTRNLM'];
                 $temp_isi[] = $row['KDKMKTRNLM'];
                 $temp_isi[] = $row['NLAKHTRNLM'];
                 $temp_isi[] = $row['BOBOTTRNLM'];
                 $temp_isi[] = $row['KELASTRNLM'];
                 ++$x;
             }
         }
         //var_dump($temp_isi);
         //echo $x;
     } else {
         echo "Tida bisa membuka tabel TRNLM. Silahkan cek kembali Settingan Anda";
     }
     //$data['isi_db'] = $temp_isi;
     var_dump($temp_isi);
     echo $x;
 }
Example #29
0
 /**
  * Places a row from the result set into the given array
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * This method is not meant to be called directly.  Use
  * DB_result::fetchInto() instead.  It can't be declared "protected"
  * because DB_result is a separate object.
  *
  * @param resource $result    the query result resource
  * @param array    $arr       the referenced array to put the data in
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch (0 = first row)
  *
  * @return mixed  DB_OK on success, NULL when the end of a result set is
  *                 reached or on failure
  *
  * @see DB_result::fetchInto()
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum === null) {
         $rownum = $this->res_row[(int) $result]++;
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $arr = @dbase_get_record_with_names($this->connection, $rownum);
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @dbase_get_record($this->connection, $rownum);
     }
     if (!$arr) {
         return null;
     }
     if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
         $this->_rtrimArrayValues($arr);
     }
     if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
         $this->_convertNullArrayValuesToEmpty($arr);
     }
     return DB_OK;
 }
Example #30
0
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>";
echo "record count = " . xbase_numrecords($xi) . " <br>";
echo "<table>";
for ($i = 0; $i < xbase_numrecords($xi); $i++) {
    echo "<tr>";
    $r = xbase_get_record_with_names($xi, $i + 1);