Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function open_dir()
- {
- $dir = FCPATH . '/tap';
- $tamp = array();
- // Open a directory, and read its contents
- if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) {
- if (substr($file, -3) == "bin") {
- array_push($tamp, $file);
- }
- }
- closedir($dh);
- }
- }
- return $tamp;
- }
- public function open($title)
- {
- // print_r($data);
- $file = file('tap/' . $title);
- $tamp = array();
- foreach ($file as $line) {
- if (strpos($line, ":")) {
- $charSet = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $line);
- $charSet = trim(strtolower($charSet));
- $r_data = str_replace(' ', '', $charSet);
- $row = explode(":", $r_data);
- $key = array($row[0]);
- $val = array(str_replace(',', '', $row[1]));
- $x_tamp = array_combine($key, $val);
- array_push($tamp, $x_tamp);
- }
- }
- return $tamp;
- }
- public function read_data()
- {
- $dir = $this->open_dir();
- echo "<pre>";
- for ($i = 0; $i < count($dir); $i++) {
- $data_file = $this->open($dir[$i]);
- // echo "nama File =================================== > " . $dir[$i] . '<br>';
- foreach ($data_file as $txt) {
- // $npwpd = $txt['npwpd'];
- // echo $npwpd;
- // $noorder = $txt['noorder']; // Misalnya
- // $checkNo = $this->db->get_where('tax_transaksi', array('transaksi_noorder' => $noorder))->row();
- // if (count($checkNo) == 0) {
- // $checkWP = $this->db->get_where('tax_wajibpajak', array('wp_npwpd' => $npwpd))->row();
- // // Disini saja nanti kroscek no_order mas
- // $data_r = array(
- // 'wp_id' => $checkWP->wp_id,
- // 'transaksi_file' => $file,
- // 'transaksi_noorder' => strtoupper($noorder),
- // 'transaksi_tgl' => date('Y-m-d', strtotime($txt['tanggal'])),
- // 'transaksi_subtotal' => intval($txt['subtotal']),
- // 'transaksi_diskon' => intval($txt['diskon']),
- // 'transaksi_pajak' => intval($txt['pajakdaerah']),
- // 'transaksi_total' => intval($txt['total']),
- // 'transaksi_update' => date('Y-m-d H:i:s'),
- // );
- // $this->db->insert('tax_transaksi', $data_r);
- // }
- foreach ($txt as $label => $val) {
- echo $label . ' : ' . $val . '<br>';
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement