Ejemplo n.º 1
0
 public function index($kod)
 {
     $sql = "select i.name as izdel_name, c.naimd as detal_name, dd.nop, dd.kol, dd.nv, dd.rc/100 as rc" . ", case when dd.cen>0 then dd.cen else e.cen end, dd.depstk from doc_det dd" . " left outer join oiz i on dd.kodiz=i.kod left outer join pt c on dd.koddet=c.kodd left outer join eco_cennic e on dd.koddet=e.koddet where dd.kod={$kod} and dd.kol>0 order by dd.npp ";
     $structura = array(array('name' => 'IZD', 'type' => 'C', 'size' => 40, 'NOCPTRANS' => true), array('name' => 'DET', 'type' => 'C', 'size' => 60, 'NOCPTRANS' => true), array('name' => 'NOP', 'type' => 'N', 'size' => 10, 'declength' => 0, 'NOCPTRANS' => true), array('name' => 'KOL', 'type' => 'N', 'size' => 10, 'declength' => 0, 'NOCPTRANS' => true), array('name' => 'MIN', 'type' => 'N', 'size' => 15, 'declength' => 3, 'NOCPTRANS' => true), array('name' => 'ZP', 'type' => 'N', 'size' => 15, 'declength' => 5, 'NOCPTRANS' => true), array('name' => 'MAT', 'type' => 'N', 'size' => 15, 'declength' => 5, 'NOCPTRANS' => true), array('name' => 'DEPSTK', 'type' => 'N', 'size' => 3, 'declength' => 0, 'NOCPTRANS' => true));
     /*$this->db->query( "SET NAMES 'WIN1251'" );
     	$result = $this->db->query( $sql );
         for ( $i = 0; $i < $result->num_rows( ); $i++ ) {
           $model[] = array_values( $result->row_array( $i ) );
     	}
     	DBF::write( 'nzp16cp1251.dbf', $structura, $model  );*/
     echo 123;
     $this->db->query("SET NAMES 'WIN866'");
     $result = $this->db->query($sql);
     for ($i = 0; $i < $result->num_rows(); $i++) {
         $model866[] = array_values($result->row_array($i));
     }
     DBF::write("../nzpi_{$kod}_cp866.dbf", $structura, $model866);
     echo 456;
     //chmod('nzp16cp1251.dbf', 0777);
     //chmod("../nzpi160_{$kod}_cp866.dbf", 0777);
     $structura[] = array('name' => 'KODDET', 'type' => 'N', 'size' => 10, 'declength' => 0, 'NOCPTRANS' => true);
     $sql = "select i.name as izdel_name, c.naimd as detal_name, dd.nop, dd.kol, dd.nv, dd.rc/100 as rc, e.cen, dd.depstk, dd.koddet from doc_det dd" . " left outer join oiz i on dd.kodiz=i.kod left outer join pt c on dd.koddet=c.kodd left outer join eco_cennic e on dd.koddet=e.koddet where dd.kod={$kod} and dd.kol>0 order by dd.npp ";
     $this->db->query("SET NAMES 'WIN1251'");
     $result = $this->db->query($sql);
     for ($i = 0; $i < $result->num_rows(); $i++) {
         $model1251[] = array_values($result->row_array($i));
     }
     DBF::write("test_{$kod}_cp1251.dbf", $structura, $model1251);
     echo 478;
 }
Ejemplo n.º 2
0
 public function index($kod)
 {
     $sql = "select i.name as izdel_name, c.naimd as detal_name, dd.nop, dd.kol, dd.nv, dd.rc/100 as rc" . ", case when dd.cen>0 then dd.cen else e.cen end, dd.depstk " . ",(select depstk from eco_cennic lec where dd.koddet=lec.koddet and dd.nop>=lec.nop order by lec.nop desc limit 1) as ec_depstk" . " from doc_det dd" . " left outer join oiz i on dd.kodiz=i.kod" . " left outer join pt c on dd.koddet=c.kodd" . " left outer join eco_cennic e on dd.koddet=e.koddet and e.nop=0" . " where dd.kod={$kod} and dd.kol>0 order by dd.npp ";
     $structura = array(array('name' => 'IZD', 'type' => 'C', 'size' => 40, 'NOCPTRANS' => true), array('name' => 'DET', 'type' => 'C', 'size' => 60, 'NOCPTRANS' => true), array('name' => 'NOP', 'type' => 'N', 'size' => 10, 'declength' => 0, 'NOCPTRANS' => true), array('name' => 'KOL', 'type' => 'N', 'size' => 10, 'declength' => 0, 'NOCPTRANS' => true), array('name' => 'MIN', 'type' => 'N', 'size' => 15, 'declength' => 3, 'NOCPTRANS' => true), array('name' => 'ZP', 'type' => 'N', 'size' => 15, 'declength' => 5, 'NOCPTRANS' => true), array('name' => 'MAT', 'type' => 'N', 'size' => 15, 'declength' => 5, 'NOCPTRANS' => true), array('name' => 'DEPSTK', 'type' => 'N', 'size' => 3, 'declength' => 0, 'NOCPTRANS' => true));
     echo 123;
     $this->db->query("SET NAMES 'WIN866'");
     $result = $this->db->query($sql);
     for ($i = 0; $i < $result->num_rows(); $i++) {
         $model866[$i] = array_values($result->row_array($i));
         if ($model866[$i][7] == 0) {
             $model866[$i][7] = $model866[$i][8];
         } else {
             if ($model866[$i][7] == 160) {
                 $model866[$i][7] = 0;
             }
         }
     }
     DBF::write("../nzpi_{$kod}_cp866.dbf", $structura, $model866);
     echo 456;
 }
Ejemplo n.º 3
0
<?php

require_once 'dbf.php';
// Ruta al archivo dbase
$directorio_de_archivos = "./DBFWEB/";
$archivos_dbf = array('01INV.DBF', '01_INV.DBF', '02_CHE.DBF', '02_CPC.DBF');
foreach ($archivos_dbf as $key => $archivo) {
    $ruta = $directorio_de_archivos . $archivo;
    $obj = new DBF($ruta);
    $obj->tabla_y_datos();
}
Ejemplo n.º 4
0
 private static function memodata($data, $fieldInfo)
 {
     $out = '';
     //Creation of block signature
     $out .= pack('C', 0) . pack('C', 0) . pack('C', 0) . pack('C', 0x1);
     /*Create the string of the length of the memo data with fixed string size of 8 chars.If the length is less than 
      *	8 characters then provide a left padding of 0*/
     $length = strlen($data);
     for ($i = strlen($length); $i < 8; $i++) {
         $length = '0' . $length;
     }
     $out .= pack('C', intval($length[0] . $length[1])) . pack('C', intval($length[2] . $length[3])) . pack('C', intval($length[4] . $length[5])) . pack('C', intval($length[6] . $length[7]));
     //appending data to output
     $out .= $data;
     /*Every memo record should be in multiples of the block size. So provide right padding for the memo
      *  records which have lengts not in the multiple of block size*/
     $lengthOfOut = strlen($out);
     $fraction = $lengthOfOut / self::$blockSize - floor($lengthOfOut / self::$blockSize);
     $requiredlength = $lengthOfOut + (self::$blockSize - $fraction * self::$blockSize);
     $out = str_pad($out, $requiredlength, pack('C', 0), STR_PAD_RIGHT);
     $handle = fopen(self::$FPTFileName, 'a');
     fwrite($handle, $out);
     fclose($handle);
     //Clear the cached statics for fetching the current file size
     clearstatcache();
     $totakeblockno = self::$lastBlockNo;
     self::$lastBlockNo = self::$lastBlockNo + strlen($out) / self::$blockSize;
     return str_pad($totakeblockno, 10, " ", STR_PAD_LEFT);
 }