示例#1
0
文件: dbf.php 项目: xiaoyjy/retry
 public function create_dbf($filename, $def)
 {
     if (!dbase_create($filename, $def)) {
         return cy_dt(CYE_ERROR, 'create DBF file failed!');
     }
     return cy_dt(0);
 }
示例#2
0
function file0()
{
    $_SESSION['ADPOS'] = 0;
    $max = $_SESSION['MaxData'];
    $md = $_SESSION['AD' . $max];
    BuatArrayHeader($hdr, $hdrid);
    $namadbf = "autodebet-{$_SESSION['tahun']}-{$_SESSION['prodi']}.dbf";
    $dbfheader = array(array("THSMSTRINA", 'C', 5), array("KDFAKTRINA", 'C', 1), array("KDJURTRINA", 'C', 1), array("NIMHSTRINA", 'C', 9), array("NMMHSTRINA", 'C', 30), array("TAGIHTRINA", 'N', 9, 0), array("STATUTRINA", 'C', 1), array("NLHUTTRINA", 'N', 12, 0), array("NLDENTRINA", 'N', 12, 0), array("NLSEMTRINA", 'N', 12, 0), array("NLKOKTRINA", 'N', 12, 0), array("NLSKSTRINA", 'N', 12, 0), array("NLPRATRINA", 'N', 12, 0), array("NLSKITRINA", 'N', 12, 0), array("TGDEBTRINA", 'D', 8), array("NOBPMTRINA", 'C', 10), array("JMSKSTRINA", 'N', 2, 0), array("JMPRATRINA", 'N', 2, 0));
    if (!dbase_create("autodebet/{$namadbf}", $dbfheader)) {
        echo "Gagal membuat File DBF";
        exit;
    }
    $gab = array();
    //for ($i=0; $i<sizeof($hdr); $i++) $gab[$i] = $hdr[$i] . '(' . $hdrid[$i] . ')';
    //$_hdr = implode(';', $gab) . "\n";
    //$hdr = "No;NPM;KHS;Nama;Rekening;Biaya;Potongan;Bayar;Tarik;TotalSKS;BPM;Tagih;Status;$_hdr";
    $hdr = "THSMSTRINA;KDFAKTRINA;KDJURTRINA;NIMHSTRINA;NMMHSTRINA;TAGIHTRINA;STATUTRINA;NLHUTTRINA(30);NLDENTRINA(35);NLSEMTRINA(11);NLKOKTRINA(8);NLSKSTRINA(5);NLPRATRINA(6);NLSRITRINA(38);TGDEBTRINA;NOBPMTRINA;JMSKSTRINA;JMPRATRINA;\n";
    //fwrite($f,"NIM;Nama;Tagihan;Autodebet;BPM;Sumbangan;BPS;Pokok;BPP SKS;Skripsi;Praktikum;Ospek;Hutang;Denda;Status;\n");
    // Buat file
    $nmf = HOME_FOLDER . DS . "tmp/{$_SESSION['_Login']}.autodebet.csv";
    $f = fopen($nmf, 'w');
    //fwrite($f, $hdr);
    //fwrite($f,"NIM;Nama;Tagihan;Autodebet;BPM;Sumbangan;BPS;Pokok;BPP SKS;Skripsi;Praktikum;Ospek;Hutang;Denda;Status;\n");
    fwrite($f, "THSMSTRINA(5~C);KDFAKTRINA(1~C);KDJURTRINA(1~C);NIMHSTRINA(9~C);NMMHSTRINA(30~C);TAGIHTRINA(9~N);STATUTRINA(1~C);NLHUTTRINA(12~N);NLDENTRINA(12~N);NLSEMTRINA(12~N);NLKOKTRINA(12~N);NLPRATRINA(12~N);NLSKSTRINA(12~N);NLSRITRINA(12~N);TGDEBTRINA(8~D);NOBPMTRINA(10~N);JMSKSTRINA(2~N);JMPRATRINA(2~N);\n");
    fclose($f);
    // Buat file header
    $nmf = HOME_FOLDER . DS . "tmp/{$_SESSION['_Login']}.autodebet.hdr.csv";
    $f = fopen($nmf, 'w');
    fwrite($f, $hdr);
    fclose($f);
    echo "<p>\r\n  Inisialisasi\r\n  &raquo; Proses Keuangan</font>\r\n  &raquo; <font size=+2><b>Buat File Bank</b></font>\r\n  </p>\r\n  <p>Proses ini akan membuat file untuk bank.</p>\r\n  <p><IFRAME src='cetak/autodebet1.php?WZRD=file0' frameborder=0 height=300 width=300>\r\n  </IFRAME></p>\r\n  <p>Setelah proses ini selesai, Anda dapat mendownload file untuk bank.</p>\r\n  ";
}
示例#3
0
文件: dbase.php 项目: naao/myshop
 /**
  * Export  data
  * @return boolean
  */
 function export()
 {
     $def = array(array('o_id', 'N', 10, 0), array('o_uid', 'N', 10, 0), array('o_date', 'D'), array('o_state', 'N', 1, 0), array('o_ip', 'C', 32), array('o_lastname', 'C', 155), array('o_firstnam', 'C', 155), array('o_adress', 'C', 155), array('o_zip', 'C', 30), array('o_town', 'C', 155), array('o_country', 'C', 3), array('o_telephon', 'C', 30), array('o_email', 'C', 155), array('o_articles', 'N', 10, 0), array('o_total', 'N', 10, 2), array('o_shipping', 'N', 10, 2), array('o_bill', 'L'), array('o_password', 'C', 155), array('o_text', 'C', 155), array('o_cancel', 'C', 155), array('c_id', 'N', 10, 0), array('c_prod_id', 'N', 10, 0), array('c_qte', 'N', 10, 0), array('c_price', 'N', 10, 2), array('c_o_id', 'N', 10, 0), array('c_shipping', 'N', 10, 2), array('c_pass', 'C', 155));
     /*
      * Correspondances
      * cmd_id				   o_id
      * cmd_uid                 o_uid
      * cmd_date                o_date
      * cmd_state               o_state
      * cmd_ip                  o_ip
      * cmd_lastname            o_lastname
      * cmd_firstname           o_firstnam
      * cmd_adress              o_adress
      * cmd_zip                 o_zip
      * cmd_town                o_town
      * cmd_country             o_country
      * cmd_telephone           o_telephon
      * cmd_email               o_email
      * cmd_articles_count      o_articles
      * cmd_total               o_total
      * cmd_shipping            o_shipping
      * cmd_bill                o_bill
      * cmd_password            o_password
      * cmd_text                o_text
      * cmd_cancel              o_cancel
      * caddy_id                c_id
      * caddy_product_id        c_prod_id
      * caddy_qte               c_qte
      * caddy_price             c_price
      * caddy_cmd_id            c_o_id
      * caddy_shipping          c_shipping
      * caddy_pass              c_pass
      */
     if (!dbase_create($this->folder . DIRECTORY_SEPARATOR . $this->filename, $def)) {
         $this->success = false;
         return false;
     }
     $dbf = dbase_open($this->folder . DIRECTORY_SEPARATOR . $this->filename, 2);
     if ($dbf === false) {
         $this->success = false;
         return false;
     }
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('cmd_id', 0, '<>'));
     $criteria->add(new Criteria('cmd_state', $this->orderType, '='));
     $criteria->setSort('cmd_date');
     $criteria->setOrder('DESC');
     $orders = $this->handlers->h_myshop_commands->getObjects($criteria);
     foreach ($orders as $order) {
         $carts = array();
         $carts = $this->handlers->h_myshop_caddy->getObjects(new Criteria('caddy_cmd_id', $order->getVar('cmd_id'), '='));
         foreach ($carts as $cart) {
             dbase_add_record($dbf, array($order->getVar('cmd_id'), $order->getVar('cmd_uid'), date('Ymd', strtotime($order->getVar('cmd_date'))), $order->getVar('cmd_state'), $order->getVar('cmd_ip'), $order->getVar('cmd_lastname'), $order->getVar('cmd_firstname'), $order->getVar('cmd_adress'), $order->getVar('cmd_zip'), $order->getVar('cmd_town'), $order->getVar('cmd_country'), $order->getVar('cmd_telephone'), $order->getVar('cmd_email'), $order->getVar('cmd_articles_count'), $order->getVar('cmd_total'), $order->getVar('cmd_shipping'), $order->getVar('cmd_bill'), $order->getVar('cmd_password'), $order->getVar('cmd_text'), $order->getVar('cmd_cancel'), $cart->getVar('caddy_id'), $cart->getVar('caddy_product_id'), $cart->getVar('caddy_qte'), $cart->getVar('caddy_price'), $cart->getVar('caddy_cmd_id'), $cart->getVar('caddy_shipping'), $cart->getVar('caddy_pass')));
         }
     }
     dbase_close($dbf);
     $this->success = true;
     return true;
 }
示例#4
0
 public function criar($array)
 {
     $this->conexao = dbase_create($this->caminho, $array);
     if ($this->conexao == false) {
         return false;
     }
     return $this->conexao;
 }
示例#5
0
 function DBFCreate($arrDef)
 {
     if (is_array($arrDef)) {
         if (dbase_create($this->DBFFile, $arrDef)) {
             $ret = TRUE;
         } else {
             $ret = FALSE;
         }
     } else {
         die("Tipe data bukan Array nih ye");
     }
     return $ret;
 }
示例#6
0
 public static function create($filename, array $fieldDefinitions)
 {
     if (!file_exists($filename)) {
         throw new RuntimeException(sprintf('Filename %s not found', $filename));
     }
     if (!function_exists('dbase_create')) {
         throw new RuntimeException(sprintf('Extension dBase not support with your PHP interpreter'));
     }
     $dbaseId = @dbase_create($filename, $fieldDefinitions);
     if (false === $dbaseId) {
         throw new RuntimeException(sprintf('Failed to create database file %s', $filename));
     }
     return new self($dbaseId);
 }
 function mspti()
 {
     $this->layout = 'ajax';
     $this->autoRender = FALSE;
     // database "definition"
     $def = array(array("KDYYSMSPTI", "C", 7), array("KDPTIMSPTI", "C", 6), array("NMPTIMSPTI", "C", 50), array("ALMT1MSPTI", "C", 30), array("ALMT2MSPTI", "C", 30), array("KOTAAMSPTI", "C", 20), array("KDPOSMSPTI", "C", 5), array("TELPOMSPTI", "C", 20), array("FAKSIMSPTI", "C", 20), array("TGPTIMSPTI", "D"), array("NOMSKMSPTI", "C", 30), array("EMAILMSPTI", "C", 40), array("HPAGEMSPTI", "C", 40), array("TGAWLMSPTI", "D"));
     $epsbed_file = EPSBED_DIR . 'MSPTI.dbf';
     if (!dbase_create($epsbed_file, $def)) {
         echo "Error, can't create the database\n";
         exit;
     } else {
         $db = dbase_open($epsbed_file, 2);
         if ($db) {
             $this->loadModel('Configuration');
             $yys = $this->Configuration->getPTI();
             $yys['YYS_KODE'] = '';
             dbase_add_record($db, array($yys['YYS_KODE'], $yys['PTI_KODE'], $yys['PTI_NAMA'], $yys['PTI_ALAMAT_1'], $yys['PTI_ALAMAT_2'], $yys['PTI_KOTA'], $yys['PTI_KODE_POS'], $yys['PTI_TELEPON'], $yys['PTI_FAX'], str_replace('-', '/', $yys['PTI_TANGGAL_SK']), $yys['PTI_NOMOR_SK'], $yys['PTI_EMAIL'], $yys['PTI_WEBSITE'], str_replace('-', '/', $yys['PTI_TANGGAL_BERDIRI'])));
             echo "<a href='files/epsbed/MSPTI.dbf'>Download file MSPTI.dbf</a>";
             dbase_close($db);
         }
     }
 }
示例#8
0
 function crea_orden_pago()
 {
     $this->load->dbforge();
     if (extension_loaded('dbase')) {
         $item_orden = array(array('nro_op', 'N', 8, 0), array('orden_nro', 'C', 8), array('tipo_pres', 'C', 20), array('fecha_op', 'C', 10), array('benef_op', 'C', 50), array('cedb_op', 'C', 15), array('autor1_op', 'C', 50), array('compr_op', 'C', 20), array('monto_op', 'N', 10, 2), array('descrip_op', 'C', 1000));
         if (!dbase_create('/tmp/orden_pago.dbf', $item_orden)) {
             echo "Error, can't create the database\n";
         } else {
             $item_orden = dbase_open('/tmp/orden_pago.dbf', 2);
             $query = "SELECT a.numero,a.numero numero2,a.fondo,a.fecha,c.nombre,c.rif,c.contacto,a.compromiso,a.total2,a.observa\n\t\t\t\tFROM v_pagos a \n\t\t\t\tJOIN sprv c ON a.cod_prov=c.proveed\n\t\t\t\tLEFT JOIN v_presaldo b ON a.codigoadm=b.codigoadm AND a.fondo=b.fondo AND a.codigopres=b.codigo\n\t\t\t\tWHERE MID(status,2,1) IN (2,3) \n\t\t\t\tGROUP BY a.numero";
             $mSQL = $this->db->query($query);
             $datos = array();
             foreach ($mSQL->result() as $row) {
                 $datos[0] = $row->numero;
                 $datos[1] = $row->numero2;
                 $datos[2] = $row->fondo;
                 $datos[3] = $row->fecha;
                 $datos[4] = $row->nombre;
                 $datos[5] = $row->rif;
                 $datos[6] = $row->contacto;
                 $datos[7] = $row->compromiso;
                 $datos[8] = $row->total2;
                 $datos[9] = $row->observa;
                 dbase_add_record($item_orden, $datos);
             }
             dbase_close($item_orden);
         }
     }
     $this->load->helper('download');
     $data = file_get_contents("/tmp/orden_pago.dbf");
     // Read the file's contents
     $name = 'orden_pago.dbf';
     force_download($name, $data);
     unlink("/tmp/orden_pago.dbf");
 }
示例#9
0
</form>
</div>

<?
if(isset($_POST['BOK'])){

$year = $_POST['year'];
$newyear = $year-543;
$yy = substr($newyear,2,2);
$mm =$_POST['mon'];

//---------------Start Dataset15---------------//
$dbname15 = "LVD".$yy.$mm.".dbf";
	$def15 = array(
	  array("SEQLVD","C",3),
	  array("AN","C",15),
	  array("DATEOUT","D"),	  
	  array("TIMEOUT","C",4), 
	  array("DATEIN","D"),	 
	  array("TIMEIN","C",4),
	  array("QTYDAY","C",3)
	);
	
	// creation
	if (!dbase_create($dbname15, $def15)) {
	  echo "Error, can't create the database15\n";
	};
//---------------End Dataset15---------------//

}  // if check box »Ô´ÊØ´·éÒÂ
?>
示例#10
0
 /**
  * Converte um tipo de regiao em shapefile
  * @param codigo do tipo de regiao
  * @return nome do arquivo criado
  */
 function regiao2shp($codigo_tipo_regiao)
 {
     $regiao = $this->listaTipoRegiao($codigo_tipo_regiao);
     $dados = $this->obtemDadosTabelaDB($regiao["codigo_estat_conexao"], $regiao["esquemadb"], $regiao["tabela"], "sim");
     $tipol = $this->listaPropGeoRegiao($codigo_tipo_regiao);
     include_once dirname(__FILE__) . "/../../classesphp/classe_shp.php";
     $s = new SHP();
     //st_dimension returns 0 for POINT, 1 for LINESTRING, 2 for POLYGON
     //echo MS_SHP_POINT.", ".MS_SHP_ARC.", ".MS_SHP_POLYGON.", ".MS_SHP_MULTIPOINT;
     //1, 3, 5, 8
     $conv[0] = 1;
     $conv[1] = 3;
     $conv[2] = 5;
     //cria as colunas
     $cni = 0;
     foreach ($dados["colunas"] as $t) {
         $temp = strtoupper($t["field"]);
         if (strlen($temp) > 10) {
             $temp = substr($temp, 0, 8) . $cni++;
         }
         if ($t["type"] == "varchar" || $t["type"] == "char" || $t["type"] == "character varying" || $t["type"] == "character" || $t["type"] == "text") {
             $def[] = array($temp, "C", "254");
         } else {
             if ($t["lengthvar"] < 0) {
                 $t["lengthvar"] = 0;
             }
             $def[] = array($temp, "N", $t["length"], $t["lengthvar"]);
         }
     }
     $nomeshp = $this->dir_tmp . "/regiao{$codigo_tipo_regiao}" . "_" . $this->nomeRandomico();
     $dbaseExiste = false;
     if (function_exists("dbase_create")) {
         $dbaseExiste = true;
     }
     //para manipular dbf
     if ($dbaseExiste == false) {
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
         $db = xbase_create($nomeshp . ".dbf", $def);
     } else {
         $db = dbase_create($nomeshp . ".dbf", $def);
     }
     $dbname = $nomeshp . ".dbf";
     $reg = array();
     $novoshpf = ms_newShapefileObj($nomeshp . ".shp", $conv[$tipol["st_dimension"]]);
     $cols = $dados["colunas"];
     $nc = count($dados["colunas"]);
     foreach ($dados["linhas"] as $l) {
         $reg = array();
         for ($i = 0; $i < $nc; $i++) {
             if ($cols[$i]["type"] != "geometry" && $cols[$i]["type"] != "geography") {
                 $reg[] = $l[$i];
             } else {
                 $reg[] = 0;
                 if ($cols[$i]["field"] == $regiao["colunageo"]) {
                     $shape = ms_shapeObjFromWkt($l[$i]);
                 }
             }
         }
         $novoshpf->addShape($shape);
         if ($dbaseExiste == false) {
             xbase_add_record($db, $reg);
         } else {
             dbase_add_record($db, $reg);
         }
     }
     if ($this->dbaseExiste == false) {
         xbase_close($db);
     } else {
         dbase_close($db);
     }
     return $nomeshp;
 }
示例#11
0
	$newcredit = "¨èÒµç Í»·.";
}

//--------------------Start DataSet3-------------------------//
$dbname3 = "OPD".$yy.$mm.".dbf";
	$def3 = array(
	  array("HN","C",15),
	  array("CLINIC","C",4),
	  array("DATEOPD","D"),
	  array("TIMEOPD","C",4),
	  array("SEQ","C",15),
	  array("UUC","C",1)
	);

	// creation
	if (!dbase_create($dbname3, $def3)) {
	  echo "Error, can't create the database OPD\n";
	}
	if($day=="00"){
		$sqlop3 ="select hn, txdate from  opacc  where credit like '$newcredit%' and (date between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59') group by substring(date,1,10), hn";
		//echo "test-->".$sqlop3."<br>";
	}else{
		$sqlop3 ="select hn, txdate from  opacc  where credit like '$newcredit%' and (date between '".$_POST['year']."-".$_POST['mon']."-".$_POST['day']." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-".$_POST['day']." 23:59:59') group by substring(date,1,10), hn";
		//echo "test-->".$sqlop3."<br>";
	}
   		$resultop3 = mysql_query($sqlop3) or die("Query failed3");
		while($rowsop3 = mysql_fetch_array($resultop3)){
			$hnop=$rowsop3["hn"];	
			
			$datetime=$rowsop3["txdate"];
			$dateopacc = substr($datetime,0,10);	
示例#12
0
* 
*  Developer        : Erwin Kooi
*  released at      : Jan 2005
*  last modified by : Erwin Kooi
*  date modified    : Jan 2005
*                                                               
*  Info? Mail to info@cyane.nl
* 
* --------------------------------------------------------------
*
* R/W with api demonstration / compare with PHP integrated dbase functions
*
**/
require_once "api_conversion.php";
$fields = array(array("bool", DBFFIELD_TYPE_LOGICAL), array("memo", DBFFIELD_TYPE_MEMO), array("date", DBFFIELD_TYPE_DATE), array("number", DBFFIELD_TYPE_NUMERIC, 3, 0), array("string", DBFFIELD_TYPE_CHAR, 50));
$di = dbase_create("test/dbase.dbf", $fields);
$xi = xbase_create("test/xbase.dbf", $fields);
dbase_add_record($di, array("T", "abc", "20060120", 123, "string one"));
dbase_add_record($di, array("F", "def", "20060121", 321, "string two"));
dbase_add_record($di, array("F", "ghi", "20060121", 111, "string trio"));
xbase_add_record($xi, array("T", "abc", "20060120", 123, "string one"));
xbase_add_record($xi, array("F", "def", "20060121", 321, "string two"));
xbase_add_record($xi, array("F", "ghi", "20060121", 111, "string trio"));
dbase_close($di);
xbase_close($xi);
$di = dbase_open("test/dbase.dbf", 2);
$xi = xbase_open("test/xbase.dbf", 2);
dbase_delete_record($di, 2);
xbase_delete_record($xi, 2);
dbase_pack($di);
xbase_pack($xi);
示例#13
0
文件: request.php 项目: raprasad/iem
    $month = date('m');
}
if (strlen($day) == 0) {
    $day = date('d');
}
$ts = mktime(0, 0, 0, $month, $day, 2000);
$sqlDate = strftime('%Y-%m-%d', $ts);
$filePre = strftime('%m%d', $ts) . "_coop";
$pgcon = iemdb("coop");
$rs = pg_exec($pgcon, "select c.*, \n   to_char(c.valid, 'YYYYMMDD') as cvalid from \n   climate c WHERE c.valid = '" . $sqlDate . "' ");
pg_close($pgcon);
@mkdir("/tmp/cli2shp");
chdir("/tmp/cli2shp");
$shpFname = $filePre;
$shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
$dbfFile = dbase_create($shpFname . ".dbf", array(array("SITE", "C", 6), array("NAME", "C", 50), array("CRECORD", "N", 5, 0), array("DATE", "D"), array("AVG_HIGH", "N", 3, 0), array("AVG_LOW", "N", 3, 0), array("AVG_PREC", "N", 8, 2), array("MAX_PREC", "N", 8, 2), array("MAX_PR_YR", "N", 4, 0), array("MAX_HIGH", "N", 3, 0), array("MAX_LOW", "N", 3, 0), array("MIN_HIGH", "N", 3, 0), array("MIN_LOW", "N", 3, 0), array("MAX_HI_YR", "N", 4, 0), array("MAX_LO_YR", "N", 4, 0), array("MIN_HI_YR", "N", 4, 0), array("MIN_LO_YR", "N", 4, 0)));
for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) {
    addPoint($row, $cities[strtoupper($row["station"])]["lon"], $cities[strtoupper($row["station"])]["lat"], $cities[strtoupper($row["station"])]["name"]);
}
// End of for
$shpFile->free();
dbase_close($dbfFile);
// Generate zip file
copy("/mesonet/www/apps/iemwebsite/data/gis/meta/4326.prj", $filePre . ".prj");
popen("zip " . $filePre . ".zip " . $filePre . ".shp " . $filePre . ".shx " . $filePre . ".dbf " . $filePre . ".prj", 'r');
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename={$filePre}.zip");
readfile("{$filePre}.zip");
unlink("{$filePre}.zip");
unlink("{$filePre}.shp");
unlink("{$filePre}.prj");
示例#14
0
 function incmapageometrias($dir_tmp, $imgdir, $lista, $tipoLista = "stringArquivos")
 {
     $dir = $dir_tmp . "/" . $imgdir . "/";
     $tituloTema = " geometria";
     if ($tipoLista == "stringArquivos") {
         $lista = explode(",", $lista);
         $shapes = array();
         $valoresoriginais = array();
         foreach ($lista as $l) {
             $geos = $this->unserializeGeo($dir . $l);
             // pega todas as geometrias
             foreach ($geos["dados"] as $geo) {
                 // echo $geo["wkt"]."<br>";
                 $shapes[] = ms_shapeObjFromWkt(str_replace("'", "", $geo["wkt"]));
                 foreach ($geo["valores"] as $v) {
                     $valorestemp[] = $v["item"] . "=" . $v["valor"];
                 }
                 $valoresoriginais[] = implode(" ", $valorestemp);
             }
         }
     }
     if ($tipoLista == "arraywkt") {
         $shapes = array();
         $valoresoriginais = array();
         foreach ($lista as $l) {
             $shapes[] = ms_shapeObjFromWkt($l);
         }
     }
     if ($tipoLista == "marcadores") {
         $shapes = array();
         $valoresoriginais = array();
         foreach ($lista as $l) {
             $valoresoriginais[] = $l["nome"];
             $p = explode(" ", $l["ext"]);
             $l = "POLYGON ((" . $p[0] . " " . $p[1] . "," . $p[0] . " " . $p[3] . "," . $p[2] . " " . $p[3] . "," . $p[2] . " " . $p[1] . "," . $p[0] . " " . $p[1] . "))";
             $shapes[] = ms_shapeObjFromWkt($l);
         }
         $tituloTema = " marcadores";
     }
     // verifica o tipo
     if (count($shapes) == 0) {
         return "erro.";
     }
     $tiposhape = $shapes[0]->type;
     $tiposhapefile = MS_SHP_POLYGON;
     if ($tiposhape == 0) {
         $tiposhapefile = MS_SHP_MULTIPOINT;
     }
     if ($tiposhape == 1) {
         $tiposhapefile = MS_SHP_ARC;
     }
     // cria o shapefile
     if ($this->dbaseExiste == false) {
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
     }
     $diretorio = dirname($this->arquivo);
     $novonomelayer = nomeRandomico();
     $nomeshp = $diretorio . "/" . $novonomelayer;
     $l = criaLayer($this->mapa, $tiposhape, MS_DEFAULT, "Ins", "SIM");
     $novoshpf = ms_newShapefileObj($nomeshp, $tiposhapefile);
     $def[] = array("ID", "C", "250");
     if ($this->dbaseExiste == false) {
         $db = xbase_create($nomeshp . ".dbf", $def);
         xbase_close($db);
     } else {
         $db = dbase_create($nomeshp . ".dbf", $def);
         dbase_close($db);
     }
     // acrescenta os pontos no novo shapefile
     $dbname = $nomeshp . ".dbf";
     if ($this->dbaseExiste == false) {
         $db = xbase_open($dbname, 2);
     } else {
         $db = dbase_open($dbname, 2);
     }
     $conta = 0;
     foreach ($shapes as $s) {
         $reg = array();
         $reg[] = $valoresoriginais[$conta];
         if ($this->dbaseExiste == false) {
             xbase_add_record($db, $reg);
         } else {
             dbase_add_record($db, $reg);
         }
         $novoshpf->addshape($s);
         $conta = $conta + 1;
     }
     if ($this->dbaseExiste == false) {
         xbase_close($db);
     } else {
         dbase_close($db);
     }
     $l->set("opacity", 80);
     $l->setmetadata("tema", $novonomelayer . $tituloTema);
     $l->setmetadata("TEMALOCAL", "SIM");
     $l->setmetadata("DOWNLOAD", "sim");
     $l->set("data", $nomeshp);
     $l->set("name", $novonomelayer);
     $classe = $l->getclass(0);
     $estilo = $classe->getstyle(0);
     if ($tiposhape == 0) {
         $estilo->set("symbolname", "ponto");
         $estilo->set("size", 6);
     }
     $cor = $estilo->color;
     $cor->setrgb(255, 210, 0);
     $cor = $estilo->outlinecolor;
     $cor->setrgb(255, 0, 0);
     $this->salva();
     return $novonomelayer;
 }
示例#15
0

//--------------------Start DataSet6-------------------------//
$dbname6 = "OOP".$yy.$mm.".dbf";
	$def6 = array(
	  array("HN","C",15),
	  array("DATEOPD","D"),
	  array("CLINIC","C", 4),	  
	  array("OPER","C",7),
	  array("DROPID","C",6),
	  array("PERSON_ID","C",13),	  
	  array("SEQ","C",15)
	);

	// creation
	if (!dbase_create($dbname6, $def6)) {
	  echo "Error, can't create the database6\n";
	}

		$sql6 ="select * from opicd9cm  where (svdate between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59') order by row_id";
		$result6 = mysql_query($sql6) or die("Query failed6");
   		while($rows6 = mysql_fetch_array($result6)){
		$hn6=$rows6["hn"];   //  HN Ц╙И╣ягА╩ц╧уИ╧сЮ╒Ир╒Имаые
		$oper6=$rows6["icd9cm"];   //  OPER Ц╙И╣ягА╩ц╧уИ╧сЮ╒Ир╒Имаые
		
		//DATEOPD
		$dateopd6=$rows6["svdate"];
		$date6 = substr($dateopd6,0,10);
		$date =explode("-",$date6);
		$newdate=$date[0]-543;
		$newdateopd =$newdate.$date[1].$date[2];  //  DATEOPD Ц╙И╣ягА╩ц╧уИ╧сЮ╒Ир╒Имаые		
示例#16
0
function criaSHP($tema, $map_file, $locaplic, $dir_tmp, $nomeRand = TRUE, $prj = "", $projetaToMap = true, $shapesSel = false)
{
    include dirname(__FILE__) . "/../ms_configura.php";
    $versao = versao();
    $versao = $versao["principal"];
    //para manipular dbf
    if (file_exists($locaplic . "/pacotes/phpxbase/api_conversion.php")) {
        include_once $locaplic . "/pacotes/phpxbase/api_conversion.php";
    } else {
        include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
    }
    $map = @ms_newMapObj($map_file);
    $nameMapfile = $map->name;
    substituiConObj($map, $postgis_mapa);
    $layer = $map->getlayerbyname($tema);
    //e necessario abrir ou nao vai projetar
    $layer->open();
    $prjMapa = $map->getProjection();
    $prjTema = $layer->getProjection();
    if ($prjTema != "") {
        $projInObj = new projectionObj($prjTema);
        $projOutObj = new projectionObj($prjMapa);
    } else {
        $projInObj = "";
        $projOutObj = "";
        $projetaToMap = false;
    }
    $layer->set("template", "none.htm");
    $diretorio = dirname($dir_tmp);
    $tipol = MS_SHP_POINT;
    if ($layer->type == MS_LAYER_LINE) {
        $tipol = MS_SHP_ARC;
    }
    if ($layer->type == MS_LAYER_POLYGON) {
        $tipol = MS_SHP_POLYGON;
    }
    if ($nomeRand == true) {
        $novonomelayer = $tema . "_" . nomeRandomico(5);
    } else {
        $novonomelayer = $tema;
    }
    $novonomelayer = str_replace(".", "-", $novonomelayer);
    $nomeshp = $dir_tmp . "/" . $nameMapfile . "_" . $novonomelayer;
    if (file_exists($nomeshp . ".shp")) {
        return $nomeshp;
    }
    $novoshpf = ms_newShapefileObj($nomeshp, $tipol);
    //se for do tipo features
    $data = $layer->data;
    $resultadoFinal = true;
    if ($data == "") {
        $def[] = array("ID", "C", "50");
        $reg[] = 0;
        if (!function_exists("dbase_create")) {
            $db = xbase_create($nomeshp . ".dbf", $def);
            xbase_add_record($db, $reg);
            xbase_close($db);
        } else {
            $db = dbase_create($nomeshp . ".dbf", $def);
            dbase_add_record($db, $reg);
            dbase_close($db);
        }
        if ($versao >= 6) {
            $shape = $layer->getshape(new resultObj(0));
        } else {
            $s = $layer->getfeature(0, -1);
            $result = $layer->getResult(0);
            $shpi = $result->shapeindex;
            $shape = $layer->getfeature($shpi, -1);
        }
        $novoshpf = ms_newShapefileObj($nomeshp . ".shp", -2);
        $novoshpf->addShape($shape);
        $resultadoFinal = true;
    } else {
        if ($shapesSel == false) {
            $shapesSel = retornaShapesSelecionados($layer, $map_file, $map, false);
        }
        $items = pegaItens($layer);
        // cria o dbf
        $def = array();
        $cni = 0;
        foreach ($items as $ni) {
            $temp = strtoupper($ni);
            $temp = substr($temp, 0, 8) . $cni;
            //
            //nao tem como descobrir o tamanho e tipo do campo
            //
            $def[] = array($temp, "C", "254");
            $cni = $cni + 1;
        }
        if (!function_exists("dbase_create")) {
            $db = xbase_create($nomeshp . ".dbf", $def);
        } else {
            $db = dbase_create($nomeshp . ".dbf", $def);
        }
        $dbname = $nomeshp . ".dbf";
        $reg = array();
        $novoshpf = ms_newShapefileObj($nomeshp . ".shp", -2);
        $res_count = count($shapesSel);
        if ($res_count > 0) {
            for ($i = 0; $i < $res_count; ++$i) {
                $shape = $shapesSel[$i];
                if ($projetaToMap == true) {
                    $shape->project($projInObj, $projOutObj);
                }
                foreach ($items as $ni) {
                    $vreg = $shape->values[$ni];
                    if (strlen($vreg) > 255) {
                        $vreg = substr($vreg, 0, 255);
                    }
                    $reg[] = $vreg;
                }
                $novoshpf->addShape($shape);
                if (!function_exists("dbase_create")) {
                    xbase_add_record($db, $reg);
                } else {
                    dbase_add_record($db, $reg);
                }
                $reg = array();
            }
            if (!function_exists("dbase_create")) {
                xbase_close($db);
            } else {
                dbase_close($db);
            }
            //
            //verifica a quantidade de registros no final
            //
            if (function_exists("dbase_open")) {
                $db = dbase_open($nomeshp . ".dbf", 0);
            } else {
                $db = xbase_open($nomeshp . ".dbf", 0);
            }
            if (function_exists("dbase_numrecords")) {
                $record_numbers = dbase_numrecords($db);
            } else {
                $record_numbers = xbase_numrecords($db);
            }
            if (function_exists("dbase_close")) {
                dbase_close($db);
            } else {
                xbase_close($db);
            }
            if ($record_numbers != $res_count) {
                if (file_exists($nomeshp . ".dbf")) {
                    unlink($nomeshp . ".dbf");
                }
                if (file_exists($nomeshp . ".shp")) {
                    unlink($nomeshp . ".shp");
                }
                if (file_exists($nomeshp . ".shx")) {
                    unlink($nomeshp . ".shx");
                }
                if (file_exists($nomeshp . ".prj")) {
                    unlink($nomeshp . ".prj");
                }
                $resultadoFinal = false;
            }
        } else {
            $resultadoFinal = false;
        }
    }
    if ($resultadoFinal == false) {
        return false;
    } else {
        //gera o arquivo prj
        if ($prj != "") {
            gravaDados(array($prj), $nomeshp . ".prj");
        } elseif ($projetaToMap == false) {
            $nomePrjOriginal = str_replace(".shp", ".prj", $layer->data);
            $nomeDestino = $nomeshp . ".prj";
            if (file_exists($nomePrjOriginal) && !file_exists($nomeDestino)) {
                copy($nomePrjOriginal, $nomeDestino);
            }
        }
        return $nomeshp;
    }
}
示例#17
0
//---------------Start Dataset10---------------//
$dbname10 = "IOP".$yy.$mm.".dbf";
	$def10 = array(
	  array("AN","C",15),		  
	  array("OPER","C",7),		  
	  array("OPTYPE","C",1),
	  array("DROPID","C",6),
	  array("DATEIN","D"),	  
 	  array("TIMEIN","C",4),
	  array("DATEOUT","D"),	 
	  array("TIMEOUT","C",4)
	);
	
	// creation
	if (!dbase_create($dbname10, $def10)) {
	  echo "Error, can't create the database10\n";
	}
	
	$sqliop ="select * from ipcard where dcdate between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59'";   //  Query ��Ң����Ũҡ���ҧ ipcard
	$resultiop = mysql_query($sqliop) or die("Query IOP Failed");
   	while($rowsiop = mysql_fetch_array($resultiop)){
		$aniop=$rowsiop["an"]; //  AN �����ù�����Ң�����
		//$dateidx = substr($rowsiop["dcdate"],0,10);
		

		$sql10 ="select * from ipicd9cm  where an ='".$aniop."' ";    //  Query ��Ң����Ũҡ���ҧ ipicd9cm
		$result10 = mysql_query($sql10) or die("Query failed10");
		$num10 =mysql_num_rows($result10);
		//echo "�ӹǹ : $num10";
		if($num10 > 1 ){
示例#18
0
	$def14 = array(
	  array("HN","C",15),
	  array("AN","C",15),
	  array("DATEOPD","D"),	  
	  array("TYPE","C",2), 
	  array("CODE","C",11),	 
	  array("QTY","N",3,0),
	  array("RATE","N",7, 0),
	  array("SEQ","C",15),
	  array("CAGCODE","C",10),
	  array("DOSE","C",10),
	  array("CA_TYPE","C",1)
	);
	
	// creation
	if (!dbase_create($dbname14, $def14)) {
	  echo "Error, can't create the database14\n";
	}
	





//--------------------------------- �������¼������	---------------------------------//	
$dbsql ="select * from  ipcard  where dcdate between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59'";
$dbresult = mysql_query($dbsql) or die("Query ipcard failed14");
while($rowsdb = mysql_fetch_array($dbresult)){
	$hn14=$rowsdb["hn"];  //  HN �����ù�����Ң�����	
	$an14=$rowsdb["an"]; //  AN �����ù�����Ң�����
					
示例#19
0
function inserePoligonosUrl()
{
    global $tamanhosimbolo, $simbolo, $corsimbolo, $poligonos, $nometemapoligonos, $dir_tmp, $imgdir, $tmpfname, $locaplic;
    include_once "pacotes/phpxbase/api_conversion.php";
    if (!isset($nometemapoligonos)) {
        $nometemapoligonos = "Poligonos";
    }
    if ($nometemapoligonos == "") {
        $nometemapoligonos = "Poligonos";
    }
    //
    //cria o shape file
    //
    $tipol = MS_SHP_POLYGON;
    $nomeshp = $dir_tmp . "/" . $imgdir . "/poligonosins";
    // cria o dbf
    $def = array();
    $items = array("COORD");
    foreach ($items as $ni) {
        $def[] = array($ni, "C", "254");
    }
    if (!function_exists(dbase_create)) {
        xbase_create($nomeshp . ".dbf", $def);
    } else {
        dbase_create($nomeshp . ".dbf", $def);
    }
    $dbname = $nomeshp . ".dbf";
    $db = xbase_open($dbname, 2);
    $novoshpf = ms_newShapefileObj($nomeshp, $tipol);
    $linhas = explode(",", trim($poligonos));
    $pontosLinhas = array();
    //guarda os pontos de cada linha em arrays
    foreach ($linhas as $l) {
        $tempPTs = explode(" ", trim($l));
        $temp = array();
        foreach ($tempPTs as $p) {
            if (is_numeric($p)) {
                $temp[] = $p;
            }
        }
        $pontosLinhas[] = $temp;
    }
    foreach ($pontosLinhas as $ptsl) {
        $linhas = $ptsl;
        $shape = ms_newShapeObj($tipol);
        $linha = ms_newLineObj();
        $reg = array();
        $reg[] = "";
        for ($ci = 0; $ci < count($linhas); $ci = $ci + 2) {
            $linha->addXY($linhas[$ci], $linhas[$ci + 1]);
        }
        $shape->add($linha);
        $novoshpf->addShape($shape);
        xbase_add_record($db, $reg);
    }
    $novoshpf->free();
    xbase_close($db);
    //adiciona o layer
    $mapa = ms_newMapObj($tmpfname);
    $layer = ms_newLayerObj($mapa);
    $layer->set("name", "linhains");
    $layer->set("data", $nomeshp . ".shp");
    $layer->setmetadata("DOWNLOAD", "sim");
    $layer->setmetadata("temalocal", "sim");
    $layer->setmetadata("tema", $nometemapoligonos);
    $layer->setmetadata("classe", "sim");
    $layer->setmetadata("ATLAS", "nao");
    $layer->set("type", MS_LAYER_POLYGON);
    $layer->set("opacity", "50");
    $layer->set("status", MS_DEFAULT);
    $classe = ms_newClassObj($layer);
    $classe->set("name", " ");
    $estilo = ms_newStyleObj($classe);
    $cor = $estilo->color;
    if (!isset($corsimbolo)) {
        $corsimbolo = "255,0,0";
    }
    $corsimbolo = str_replace(" ", ",", $corsimbolo);
    $corsimbolo = explode(",", $corsimbolo);
    $cor->setRGB($corsimbolo[0], $corsimbolo[1], $corsimbolo[2]);
    $salvo = $mapa->save($tmpfname);
    erroCriacao();
}
示例#20
0
	  array("DATE_SERV","D"),	  
	  array("DID","C",30), 
	  array("DIDNAME","C",255),	 
	  array("AMOUNT","C",12),
	  array("DRUGPRIC","C",14),
	  array("DRUGCOST","C",14),
	  array("DIDSTD","C",24), 
	  array("UNIT","C",20),	 
	  array("UNIT_PACK","C",20),
	  array("SEQ","C",15),
	  array("DRUGREMARK","C",2),	  
	  array("PA_NO","C",9)
	);
	
	// creation
	if (!dbase_create($dbname16, $def16)) {
	  echo "Error, can't create the database16\n";
	}
	
		$sql16 ="select * from  drugrx  where date between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59' and (an='' or an is null)";
		$result16 = mysql_query($sql16) or die("Query failed16");
		$num16= mysql_num_rows($result16);
   		while($rows16 = mysql_fetch_array($result16)){	
			$hcode16 ="11512";
			$hn16=$rows16["hn"];  //  HN �����ù�����Ң�����	
			$an16=$rows16["an"]; //  AN �����ù�����Ң�����
			$drugcode16=$rows16["drugcode"];  //  DID �����ù�����Ң�����
			$drugname16=$rows16["tradname"];  //  DIDNAME �����ù�����Ң�����
			$amount16=$rows16["amount"];  //  AMOUNT �����ù�����Ң�����
			
			$datetimedrg=$rows16["date"];
示例#21
0
	  array("HN","C",15),
	  array("AN","C",15),
	  array("DATEADM","D"),	  
	  array("TIMEADM","C",4),
	  array("DATEDSC","D"),
	  array("TIMEDSC","C",4),	  
	  array("DISCHS","C",1),
 	  array("DISCHT","C",1),
	  array("WARDDSC","C",4),
	  array("DEPT","C",2),
	  array("ADM_W","C",7),
	  array("UUC","C",1),
	);

	// creation
	if (!dbase_create($dbname7, $def7)) {
	  echo "Error, can't create the database7\n";
	};
	
	$sql7 ="select * from ipcard where dcdate between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59'";   //  Query ��Ң����Ũҡ���ҧ ipcard
	$result7 = mysql_query($sql7) or die("Query IPD Failed");
   	while($rows7 = mysql_fetch_array($result7)){
		$hn7=$rows7["hn"];  //  HN �����ù�����Ң�����
		$an7=$rows7["an"]; //  AN �����ù�����Ң�����
	
		//datetimeADM
		$datetimead=$rows7["date"];
		$datead7 = substr($datetimead,0,10);
		$datead =explode("-",$datead7);
		$newdatead=$datead[0]-543;
		$newdateadm =$newdatead.$datead[1].$datead[2];  //  DATEADM�����ù�����Ң�����
示例#22
0
$mm =$_POST['mon'];

//---------------Start Dataset12---------------//
$dbname12 = "CHA".$yy.$mm.".dbf";
	$def12 = array(
	  array("HN","C",15),
	  array("AN","C",15),
	  array("DATE","D"),	  
	  array("CHRGITEM","C",2), 
	  array("AMOUNT","N",7,0),		  
 	  array("PERSON_ID","C",13),	 
	  array("SEQ","C",15)
	);
	
	// creation
	if (!dbase_create($dbname12, $def12)) {
	  echo "Error, can't create the database11\n";
	}	
	
	
	
		//--------------------------------- �������¼����¹͡	---------------------------------//	
		$sql12 ="select * from  opacc  where (date between '".$_POST['year']."-".$_POST['mon']."-"."01"." 00:00:00' and '".$_POST['year']."-".$_POST['mon']."-"."31"." 23:59:59') and an=' '";
		$result12 = mysql_query($sql12) or die("Query failed12");
   		while($rows12 = mysql_fetch_array($result12)){	
			$hnopacc=$rows12["hn"];  //  HN �����ù�����Ң�����
			$anopacc=$rows12["an"]; //  AN �����ù�����Ң�����
			$chrgitem =$rows12["depart"];
			if($chrgitem=="PHAR"){
				$chrgitem12 ="41";
			}elseif($chrgitem=="PATHO"){
示例#23
0
 /**
  * Connect to the database and create it if it doesn't exist
  *
  * Don't call this method directly.  Use DB::connect() instead.
  *
  * PEAR DB's dbase driver supports the following extra DSN options:
  *   + mode    An integer specifying the read/write mode to use
  *              (0 = read only, 1 = write only, 2 = read/write).
  *              Available since PEAR DB 1.7.0.
  *   + fields  An array of arrays that PHP's dbase_create() function needs
  *              to create a new database.  This information is used if the
  *              dBase file specified in the "database" segment of the DSN
  *              does not exist.  For more info, see the PHP manual's
  *              {@link http://php.net/dbase_create dbase_create()} page.
  *              Available since PEAR DB 1.7.0.
  *
  * Example of how to connect and establish a new dBase file if necessary:
  * <code>
  * require_once 'DB.php';
  *
  * $dsn = array(
  *     'phptype'  => 'dbase',
  *     'database' => '/path/and/name/of/dbase/file',
  *     'mode'     => 2,
  *     'fields'   => array(
  *         array('a', 'N', 5, 0),
  *         array('b', 'C', 40),
  *         array('c', 'C', 255),
  *         array('d', 'C', 20),
  *     ),
  * );
  * $options = array(
  *     'debug'       => 2,
  *     'portability' => DB_PORTABILITY_ALL,
  * );
  *
  * $db = DB::connect($dsn, $options);
  * if (PEAR::isError($db)) {
  *     die($db->getMessage());
  * }
  * </code>
  *
  * @param array $dsn         the data source name
  * @param bool  $persistent  should the connection be persistent?
  *
  * @return int  DB_OK on success. A DB_Error object on failure.
  */
 function connect($dsn, $persistent = false)
 {
     if (!PEAR::loadExtension('dbase')) {
         return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
     }
     $this->dsn = $dsn;
     if ($dsn['dbsyntax']) {
         $this->dbsyntax = $dsn['dbsyntax'];
     }
     /*
      * Turn track_errors on for entire script since $php_errormsg
      * is the only way to find errors from the dbase extension.
      */
     @ini_set('track_errors', 1);
     $php_errormsg = '';
     if (!file_exists($dsn['database'])) {
         $this->dsn['mode'] = 2;
         if (empty($dsn['fields']) || !is_array($dsn['fields'])) {
             return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, 'the dbase file does not exist and ' . 'it could not be created because ' . 'the "fields" element of the DSN ' . 'is not properly set');
         }
         $this->connection = @dbase_create($dsn['database'], $dsn['fields']);
         if (!$this->connection) {
             return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, 'the dbase file does not exist and ' . 'the attempt to create it failed: ' . $php_errormsg);
         }
     } else {
         if (!isset($this->dsn['mode'])) {
             $this->dsn['mode'] = 0;
         }
         $this->connection = @dbase_open($dsn['database'], $this->dsn['mode']);
         if (!$this->connection) {
             return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $php_errormsg);
         }
     }
     return DB_OK;
 }
示例#24
0
function createDBF($fullpath_filename, $field_structure, $data, $file_mode = '0')
{
    # Constants for dbf field types
    /*
        L = BOOLEAN
        C = CHAR
        D = DATE
        N = NUMBER
    */
    # Constants for dbf file mode
    /*
        '0' = 'READ_ONLY';
        '1' = 'WRITE_ONLY';
        '2' = 'READ_WRITE';
    */
    # Path to dbf file
    $db_file = $fullpath_filename;
    if (is_dir($db_file)) {
        unlink($db_file);
    }
    # create dbf file using the
    $create = dbase_create($db_file, $field_structure);
    # open dbf file for reading and writing
    $id = @dbase_open($db_file, $file_mode) or die("Could not open dbf file <i>{$db_file}</i>.");
    if (is_array($data)) {
        foreach ($data as $dt) {
            dbase_add_record($id, $dt) or die("Could not add record {$dt['0']} to dbf file <i>{$db_file}</i>.");
        }
    }
    # close the dbf file
    dbase_close($id);
}
示例#25
0
 function writeDbf($dbfFileName, $dbfFieldList, $valueList)
 {
     $defList = array();
     foreach ($dbfFieldList as $name => $def) {
         $defList[] = array_merge(array(substr($name, 0, 10)), $def);
     }
     pm_logDebug(3, $defList, 'defList');
     $dbfFile = dbase_create($dbfFileName, $defList);
     //array(array('PROG_ID', 'N', 5, 0)));
     foreach ($valueList as $row) {
         pm_logDebug(3, $row, 'row');
         dbase_add_record($dbfFile, $row);
     }
     dbase_close($dbfFile);
 }
示例#26
0
文件: stats_dbf.php 项目: uisluu/emst
    $_GET['end_date'] = date('Y-m-d');
}
if (array_key_exists('service', $_GET)) {
    $vService = $_GET['service'];
} else {
    $vService = defautService;
}
if (!array_key_exists('paytype', $_GET)) {
    $_GET['paytype'] = 0;
}
// creation
$DBFName = tempnam('/tmp', 'stats');
rename($DBFName, $DBFName . '.dbf');
$DBFName = $DBFName . '.dbf';
$DBFDef = array(array('SURNAME', 'C', 18), array('NAME1', 'C', 15), array('NAME2', 'C', 15), array('BIRTHDAY', 'D'), array('SEX', 'C', 1), array('ORDER', 'C', 1), array('POLIS_S', 'C', 10), array('POLIS_N', 'C', 20), array('POLIS_W', 'C', 5), array('PAYER', 'C', 5), array('STREET', 'C', 45), array('STREETYPE', 'C', 2), array('AREA', 'C', 3), array('HOUSE', 'C', 7), array('KORP', 'C', 2), array('FLAT', 'C', 15), array('PROFILE', 'C', 6), array('PROFILENET', 'C', 1), array('DATEIN', 'D'), array('DATEOUT', 'D'), array('AMOUNT', 'N', 15, 5), array('DIAGNOSIS', 'C', 5), array('SEND', 'L'), array('ERROR', 'C', 25), array('TYPEDOC', 'C', 1), array('SER1', 'C', 10), array('SER2', 'C', 10), array('NPASP', 'C', 10), array('LONGADDR', 'C', 120), array('MYCASEID', 'C', 8), array('CASE_CAST', 'N', 2, 0), array('AMOUNT_D', 'N', 3, 0), array('ID_EXITUS', 'N', 2, 0), array('ILLHISTORY', 'C', 20), array('ID_PRMP', 'N', 3, 0), array('ID_PRMP_C', 'N', 3, 0), array('DIAG_C', 'C', 5), array('DIAG_S_C', 'C', 5), array('DIAG_P_C', 'C', 5), array('QRESULT', 'N', 3, 0), array('ID_PRVS', 'N', 10, 0), array('ID_PRVS_C', 'N', 10, 0), array('ID_SP_PAY', 'N', 2, 0), array('ID_ED_PAY', 'N', 5, 2), array('ID_VMP', 'N', 2, 0), array('ID_DOC', 'C', 20), array('ID_DOC_C', 'C', 20), array('ID_DEPT', 'C', 20), array('ID_DEPT_C', 'C', 20), array('ID_LPU_D', 'N', 20, 0), array('IDSERVDATA', 'N', 10, 0), array('IDSERVMADE', 'N', 1, 0), array('IDSERVLPU', 'N', 10, 0), array('ID_GOAL', 'N', 5, 0), array('ID_GOAL_C', 'N', 5, 0), array('ID_GOSP', 'N', 5, 0), array('IDVIDVME', 'N', 2, 0), array('IDFORPOM', 'N', 2, 0), array('IDVIDHMP', 'N', 2, 0), array('IDMETHMP', 'N', 2, 0), array('ID_PRVS_D', 'N', 10, 0), array('ID_GOAL_D', 'N', 5, 0));
if (!($vDBF = dbase_create($DBFName, $DBFDef))) {
    print "<strong>can't create {$DBFName}!</strong>";
    exit;
}
$vDB = GetDB();
list($vTable, $vFilter, $vOrder) = ConstructQuery($vDB, $_GET);
$vCaseID = 'not an id';
$vCase = array();
$vRecords = $vDB->Select($vTable, '*', $vFilter, $vOrder);
while ($vRecord = $vRecords->Fetch()) {
    $vRecCaseID = $vRecord['case_id'];
    if ($vCaseID !== $vRecCaseID) {
        $vCaseID = $vRecCaseID;
        $vCase = $vDB->GetById('emst_cases', $vCaseID);
    }
    if ($vCase['paytype'] == $_GET['paytype']) {
示例#27
0
 function adicionaTemaGeoRSS($servico, $dir_tmp, $locaplic, $canal)
 {
     $xml = simplexml_load_file($servico);
     $conta = 0;
     foreach ($xml->channel as $c) {
         if ($conta == $canal) {
             $canal = $c;
         }
     }
     $nos = $canal->item;
     //verifica se o canal faz referencia a elementos externos
     //se sim, usa todos os elementos do xml no lugar do canal
     foreach ($canal->items as $t) {
         foreach ($t->xpath('rdf:Seq') as $x) {
             foreach ($x->xpath('rdf:li') as $z) {
                 $nos = $xml->item;
             }
         }
     }
     $resultado = array();
     $tipog = "";
     foreach ($nos as $item) {
         $env = array();
         //define o tipo
         if ($item->xpath('geo:lat')) {
             $tipog = "geo";
         }
         if ($item->xpath('georss:point')) {
             $tipog = "georsspoint";
         }
         if ($item->xpath('georss:where')) {
             $tipog = "envelope";
         }
         if ($tipog == "envelope") {
             foreach ($item->xpath('georss:where') as $w) {
                 foreach ($w->xpath('gml:Envelope') as $e) {
                     //$lc = $e->xpath('gml:lowerCorner');
                     $lc = (string) $e->children('gml', TRUE)->lowerCorner;
                     //$uc = $e->xpath('gml:upperCorner');
                     $uc = (string) $e->children('gml', TRUE)->upperCorner;
                     $lc = explode(" ", $lc);
                     $uc = explode(" ", $uc);
                     if (is_numeric($lc[0])) {
                         $ymin = $lc[0];
                         $ymax = $uc[0];
                         $xmin = $lc[1];
                         $xmax = $uc[1];
                         if ($ymin != "") {
                             $env = array($xmin, $ymin, $xmax, $ymax);
                         }
                     }
                 }
             }
         }
         if ($tipog == "geo") {
             if ($item->xpath('geo:lon')) {
                 $x = (string) $item->children('geo', TRUE)->lon;
             } else {
                 $x = (string) $item->children('geo', TRUE)->long;
             }
             //$y = $item->xpath('geo:lat');
             $y = (string) $item->children('geo', TRUE)->lat;
             $env = array($y, $x);
         }
         if ($tipog == "georsspoint") {
             //$temp = $item->xpath('georss:point');
             $temp = (string) $item->children('georss', TRUE)->point;
             $env = explode(" ", $temp);
         }
         if (count($env) > 0) {
             $resultado[] = array(ixml($item, "title"), ixml($item, "link"), ixml($item, "description"), ixml($item, "category"), $env);
         }
     }
     //cria o shapefile com os dados
     if (count($resultado) > 0) {
         //para manipular dbf
         include_once dirname(__FILE__) . "/../pacotes/phpxbase/api_conversion.php";
         $diretorio = dirname($this->arquivo);
         $tipol = MS_SHP_POLYGON;
         if ($tipog == "georsspoint") {
             $tipol = MS_SHP_POINT;
         }
         if ($tipog == "geo") {
             $tipol = MS_SHP_POINT;
         }
         $novonomelayer = nomeRandomico(10) . "georss";
         $nomeshp = $diretorio . "/" . $novonomelayer;
         $novoshpf = ms_newShapefileObj($nomeshp, $tipol);
         $def[] = array("TITULO", "C", "254");
         $def[] = array("LINK", "C", "254");
         $def[] = array("DESC", "C", "254");
         $def[] = array("CATEGORIA", "C", "254");
         if (!function_exists(dbase_create)) {
             $db = xbase_create($nomeshp . ".dbf", $def);
             xbase_close($db);
         } else {
             $db = dbase_create($nomeshp . ".dbf", $def);
             dbase_close($db);
         }
         //acrescenta os pontos no novo shapefile
         $dbname = $nomeshp . ".dbf";
         $db = xbase_open($dbname, 2);
         $reg = array();
         $novoshpf = ms_newShapefileObj($nomeshp . ".shp", -2);
         //acrescenta os shapes
         foreach ($resultado as $r) {
             $pts = $r[4];
             if ($tipol == MS_SHP_POLYGON) {
                 $shp = ms_newShapeObj(MS_SHP_POLYGON);
                 $linha = ms_newLineObj();
                 $linha->addXY($pts[0], $pts[3]);
                 $linha->addXY($pts[2], $pts[3]);
                 $linha->addXY($pts[2], $pts[1]);
                 $linha->addXY($pts[0], $pts[1]);
                 $linha->addXY($pts[0], $pts[3]);
             } else {
                 $shp = ms_newShapeObj(MS_SHP_POINT);
                 $linha = ms_newLineObj();
                 $linha->addXY($pts[1], $pts[0]);
             }
             $shp->add($linha);
             $novoshpf->addShape($shp);
             $reg = array($r[0], $r[1], $r[2], $r[3]);
             xbase_add_record($db, $reg);
             $reg = array();
         }
         xbase_close($db);
         if ($tipog == "georsspoint" || $tipog == "geo") {
             $tipol = MS_LAYER_POINT;
         } else {
             $tipol = MS_LAYER_POLYGON;
         }
         $layer = criaLayer($this->mapa, $tipol, MS_DEFAULT, "GeoRSS", "SIM");
         $layer->set("data", $nomeshp . ".shp");
         $layer->set("name", basename($nomeshp));
         $layer->setmetadata("DOWNLOAD", "sim");
         $layer->setmetadata("TEMALOCAL", "SIM");
         //evita problemas no modo tile
         if ($this->v > 5) {
             $layer->setprocessing("LABEL_NO_CLIP=True");
             $layer->setprocessing("POLYLINE_NO_CLIP=True");
         }
         if ($tipol == MS_LAYER_POLYGON) {
             $classe = $layer->getclass(0);
             $estilo = $classe->getstyle(0);
             $estilo->set("symbolname", "p4");
             $estilo->set("size", 5);
             $cor = $estilo->color;
             $cor->setrgb(255, 0, 0);
             $coro = $estilo->outlinecolor;
             $coro->setrgb(255, 0, 0);
         }
         //$layer->set("transparency",50);
         $layer->setmetadata("nomeoriginal", basename($nomeshp));
         //echo $tipol;
         return "ok";
     }
     return "erro";
 }
示例#28
0
 function _openDBFFile($toWrite = false)
 {
     $checkFunction = $toWrite ? "is_writable" : "is_readable";
     if ($toWrite && !file_exists(str_replace('.*', '.dbf', $this->FileName))) {
         if (!@dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader)) {
             return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
         }
     }
     if ($checkFunction(str_replace('.*', '.dbf', $this->FileName))) {
         $this->DBFFile = dbase_open(str_replace('.*', '.dbf', $this->FileName), $toWrite ? 2 : 0);
         if (!$this->DBFFile) {
             return $this->setError(sprintf("It wasn't possible to open the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
         }
     } else {
         return $this->setError(sprintf("It wasn't possible to find the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName)));
     }
     return TRUE;
 }
示例#29
0
     }
     if (!$nohtml) {
         $table .= "</pre>\n";
     }
 } else {
     if ($format == "shapefile") {
         /* Create SHP,DBF bases */
         $filePre = "{$network}_locs";
         if (!is_file("/var/webtmp/{$filePre}.zip")) {
             $shpFname = "/var/webtmp/{$filePre}";
             @unlink($shpFname . ".shp");
             @unlink($shpFname . ".shx");
             @unlink($shpFname . ".dbf");
             @unlink($shpFname . ".zip");
             $shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
             $dbfFile = dbase_create($shpFname . ".dbf", array(array("ID", "C", 6), array("NAME", "C", 50), array("NETWORK", "C", 20), array("BEGINTS", "C", 16)));
             for ($i = 0; $row = @pg_fetch_array($result, $i); $i++) {
                 $pt = ms_newPointobj();
                 $pt->setXY($row["longitude"], $row["latitude"], 0);
                 $shpFile->addPoint($pt);
                 dbase_add_record($dbfFile, array($row["id"], $row["name"], $row["network"], substr($row["archive_begin"], 0, 16)));
             }
             unset($shpFile);
             dbase_close($dbfFile);
             chdir("/var/webtmp/");
             copy("/mesonet/www/apps/iemwebsite/data/gis/meta/4326.prj", $filePre . ".prj");
             popen("zip " . $filePre . ".zip " . $filePre . ".shp " . $filePre . ".shx " . $filePre . ".dbf " . $filePre . ".prj", 'r');
         }
         $table .= "Shapefile Generation Complete.<br>";
         $table .= "Please download this <a href=\"/tmp/" . $filePre . ".zip\">zipfile</a>.";
         chdir("/mesonet/www/apps/iemwebsite/htdocs/sites/");
示例#30
-3
 /**
  * Export the data for a specific mouse over s specified time range to a dbase file
  *
  * @returns url of created dbase file
  */
 function exportToDbase($rfid, $from, $to)
 {
     $parameters['rfid'] = $rfid;
     $parameters['from'] = $from;
     $parameters['to'] = $to;
     $parameters["all"] = 1;
     list($summary, $data) = $this->getRfidData($parameters);
     if (sizeof($data) == 0) {
         return null;
     }
     // boxes
     $boxes = $summary['boxes'];
     // where to store the files
     $downloadXML = $this->configXML->xpath("//downloaddir");
     $downloadDir = implode('', $downloadXML);
     $downloadUrlXML = $this->configXML->xpath("//downloadurl");
     $downloadURL = implode('', $downloadUrlXML);
     // Adding data to dbf files
     // definition for the dbf files
     $def = array(array("ID", "N", 5, 0), array("RFID", "C", 10), array("YEAR", "C", 4), array("MONTH", "C", 2), array("TIME", "C", 8), array("DATETIME", "C", 19), array("BOX", "C", 2), array("ANTENNA", "C", 2), array("X", "N", 3, 0), array("Y", "N", 3, 0));
     // create a dbf_file
     //$dbf_file = $downloadDir.$rfid . "_" . $year . "_" . $month . ".dbf";
     // $dbf_file = "data_for_" . $rfid . "_" . $from . "_" . $to . ".csv";
     $filename = "data_for_" . $rfid . "_" . $from . "_" . $to . ".dbf";
     $dbf_file = $downloadDir . $filename;
     if (!dbase_create($dbf_file, $def)) {
         return "Error, can't create the database: {$dbf_file}\n";
     }
     // open dbf file for reading and writing
     $dbf_file = dbase_open($dbf_file, 2);
     //$fh = fopen ($downloadDir.$dbf_file, "w");
     // write data
     // the datasets have the form: [rfid, antenna, box, time]
     $id = 0;
     foreach ($data as $dataset) {
         list($rfid, $antenna, $unix_time) = $dataset;
         $box = substr($antenna, 0, 2);
         $datetime = date('Y-m-d H:i:s', $unix_time);
         $month = date('m', $unix_time);
         $year = date('Y', $unix_time);
         $time = date('H:i:s', $unix_time);
         $x = $boxes["{$box}"]['x'];
         $y = $boxes[$box]['y'];
         $dataset_converted = array($id, $rfid, $year, $month, $time, $datetime, $antenna, $box, $x, $y);
         $str = implode(',', $dataset_converted) . "\n";
         //fwrite($fh, $str);
         dbase_add_record($dbf_file, $dataset_converted) or die("Could not add record to dbf file {$dbase_file}.");
         $id++;
     }
     dbase_close($dbf_file);
     //fclose($fh);
     // returning url
     return $downloadURL . $filename;
 }