db->insert($table, $data); }else{ $insert = $this->db->insert_batch($table, $data); } return $insert; } public function update($table, $data, $pk, $id = null, $batch = false) { if($batch === false){ $insert = $this->db->update($table, $data, array($pk => $id)); }else{ $insert = $this->db->update_batch($table, $data, $pk); } return $insert; } public function delete($table, $data, $pk) { $this->db->where_in($pk, $data); return $this->db->delete($table); } //Perkiraan Bebas, data berisi semua perkiraan public function getDataPerkiraan($id = null){ if ($id === null) { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); }else{ $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where(['ID_PERKIRAAN' => $id]); } return $this->db->get()->result_array(); } //Perkiraan Spesifik, tergantung dari jenis transaksinya. public function getData_Perkiraan_PiutangDagang($id = null){ if ($id == null) { $this->db->select('b.INV_PENJUALAN,c.NAMA_PELANGGAN,d.NAMA_KOTA,SUM(a.DEBET_PDA) as DEBET,SUM(a.KREDIT_PDA) as KREDIT'); $this->db->from('piutang_dagang a'); $this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID'); $this->db->join('pelanggan c','c.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota d','d.ID_KOTA=c.KOTA_ID'); $this->db->group_by('a.PENJUALAN_ID'); $this->db->having('DEBET!=KREDIT'); }else{ $this->db->select('b.INV_PENJUALAN,c.NAMA_PELANGGAN,d.NAMA_KOTA,SUM(a.DEBET_PDA) as DEBET,SUM(a.KREDIT_PDA) as KREDIT'); $this->db->from('piutang_dagang a'); $this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID'); $this->db->join('pelanggan c','c.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota d','d.ID_KOTA=c.KOTA_ID'); $this->db->group_by('a.PENJUALAN_ID'); $this->db->having('DEBET!=KREDIT'); $this->db->where(['a.PENJUALAN_ID' => $id]); } return $this->db->get()->result_array(); } public function getData_Perkiraan_HutangDagang($id = null){ if ($id == null) { $this->db->select('b.INV_PEMBELIAN,c.NAMA_SUPPLIER,d.NAMA_KOTA,SUM(a.DEBET_HDA) as DEBET,SUM(a.KREDIT_HDA) as KREDIT'); $this->db->from('hutang_dagang a'); $this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID'); $this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID'); $this->db->join('kota d','d.ID_KOTA=c.KOTA_ID'); $this->db->group_by('a.PEMBELIAN_ID'); $this->db->having('DEBET!=KREDIT'); }else{ $this->db->select('b.INV_PEMBELIAN,c.NAMA_SUPPLIER,d.NAMA_KOTA,SUM(a.DEBET_HDA) as DEBET,SUM(a.KREDIT_HDA) as KREDIT'); $this->db->from('hutang_dagang a'); $this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID'); $this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID'); $this->db->join('kota d','d.ID_KOTA=c.KOTA_ID'); $this->db->group_by('a.PEMBELIAN_ID'); $this->db->having('DEBET!=KREDIT'); $this->db->where(['a.PEMBELIAN_ID' => $id]); } return $this->db->get()->result_array(); } public function getData_Perkiraan_Lain_Kasbankmasuk() { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->like('KODE_PERKIRAAN','6', 'after'); $this->db->not_like('KODE_PERKIRAAN','6103'); $this->db->not_like('KODE_PERKIRAAN','6104'); $this->db->not_like('KODE_PERKIRAAN','6227'); $this->db->not_like('KODE_PERKIRAAN','6233'); $this->db->or_like('KODE_PERKIRAAN','7', 'after'); $this->db->not_like('KODE_PERKIRAAN','7500'); $this->db->or_like('KODE_PERKIRAAN','8', 'after'); $this->db->or_like('KODE_PERKIRAAN','9', 'after'); $this->db->or_like('KODE_PERKIRAAN','2130'); $this->db->or_like('KODE_PERKIRAAN','2140'); $this->db->or_like('KODE_PERKIRAAN','3100'); $this->db->or_like('KODE_PERKIRAAN','4130'); $this->db->or_like('KODE_PERKIRAAN','5122'); return $this->db->get()->result_array(); } public function getData_Perkiraan_Lain_Kasbankkeluar() { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->like('KODE_PERKIRAAN','6', 'after'); $this->db->not_like('KODE_PERKIRAAN','6103'); $this->db->not_like('KODE_PERKIRAAN','6104'); //$this->db->not_like('KODE_PERKIRAAN','6203'); $this->db->not_like('KODE_PERKIRAAN','6227'); $this->db->not_like('KODE_PERKIRAAN','6230'); $this->db->not_like('KODE_PERKIRAAN','6233'); $this->db->or_like('KODE_PERKIRAAN','7', 'after'); $this->db->not_like('KODE_PERKIRAAN','7500'); $this->db->or_like('KODE_PERKIRAAN','8', 'after'); $this->db->or_like('KODE_PERKIRAAN','9', 'after'); $this->db->or_like('KODE_PERKIRAAN','1180'); $this->db->or_like('KODE_PERKIRAAN','1210'); $this->db->or_like('KODE_PERKIRAAN','1220'); $this->db->or_like('KODE_PERKIRAAN','1230'); $this->db->or_like('KODE_PERKIRAAN','2130'); $this->db->or_like('KODE_PERKIRAAN','2140'); $this->db->or_like('KODE_PERKIRAAN','4130'); $this->db->or_like('KODE_PERKIRAAN','5122'); return $this->db->get()->result_array(); } public function getData_Perkiraan_FormLemburLuarKota() { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->like('KODE_PERKIRAAN','6203'); $this->db->or_like('KODE_PERKIRAAN','6233'); return $this->db->get()->result_array(); } public function getDataPerkiraanBiaya($id = null){ if ($id === null) { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where('TYPE_PERKIRAAN="BIAYA PENJUALAN"'); $this->db->or_where('TYPE_PERKIRAAN="BIAYA UMUM DAN ADMINISTRASI"'); }else{ $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where('TYPE_PERKIRAAN="BIAYA PENJUALAN"'); $this->db->or_where('TYPE_PERKIRAAN="BIAYA UMUM DAN ADMINISTRASI"'); $this->db->where(['ID_PERKIRAAN' => $id]); } return $this->db->get()->result_array(); } public function getDataPerkiraanHutang($id = null){ if ($id === null) { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where('TYPE_PERKIRAAN="KEWAJIBAN LANCAR"'); }else{ $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where('TYPE_PERKIRAAN="KEWAJIBAN LANCAR"'); $this->db->where(['ID_PERKIRAAN' => $id]); } return $this->db->get()->result_array(); } public function getDataPerkiraanPiutang($id = null){ if ($id === null) { $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where('TYPE_PERKIRAAN="AKTIVA LANCAR" AND KODE_PERKIRAAN!="1140"'); }else{ $this->db->select('*'); $this->db->from('perkiraan'); $this->db->group_by('ID_PERKIRAAN'); $this->db->order_by('KODE_PERKIRAAN'); $this->db->where('TYPE_PERKIRAAN="AKTIVA LANCAR" AND KODE_PERKIRAAN!="1140"'); $this->db->where(['ID_PERKIRAAN' => $id]); } return $this->db->get()->result_array(); } } ?>