<?php 
	defined("BASEPATH") or exit();
	class Model_jurnal extends CI_model{
		private $table = 'jurnal';
        function __construct() { 
            
			$this->db->query("SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''));");
			
		} 
		public function cek_bayar_belum_lunas($id){
			return $this->db->select('SUM(`bayar_invoice_detail`.`jml_bayar`) AS `total`,
			`bayar_invoice_detail`.`jml_bayar`,
			`bayar_invoice_detail`.`lampiran`,
			`bayar_invoice_detail`.`id_bayar`,
			`bayar_invoice_detail`.`id_sub_bayar`')
            ->from('bayar_invoice_detail')
            ->where('id_invoice',$id)
			->where('hapus',0)
            ->get();
		}
		public function sum_detail($id){
			return $this->db->select('SUM(`invoice_detail`.`jumlah` * `invoice_detail`.`harga`) AS `total`')
            ->from('invoice_detail')
            ->where('invoice_detail.id_invoice',$id)
            ->get()
            ->row()->total;
		}
		
		public function getJurnalByYear(){
            return $this->db->select('tgl_transaksi')
            ->from($this->table)
            ->group_by('year(tgl_transaksi)')
            ->order_by('id_transaksi','ASC')
            ->get()
            ->result();
		}
		
		public function sumDetail($bulan,$tahun){
			return $this->db->select('SUM(`invoice_detail`.`jumlah` * `invoice_detail`.`harga`) AS `total`')
            ->from('invoice_detail')
            ->where('month(invoice_detail.update_date)',$bulan)
            ->where('year(invoice_detail.update_date)',$tahun)
            ->get()
            ->row()->total;
		}
		
		public function sum_order($id){
			$this->db->select('SUM(`invoice_detail`.`jumlah` * `invoice_detail`.`harga`) AS `total`')
            ->from('invoice_detail')
            ->where('invoice_detail.id_invoice',$id);
			$query = $this->db->get();  
			$result = ($query->num_rows() > 0)?$query->row()->total:0; 
			return $result;
		}
		
		public function akun_detail($id)
		{
			$this->db->select('SUM(`invoice_detail`.`jumlah`*`invoice_detail`.`harga`) as total,
			`invoice`.`id_invoice`,
			`jenis_cetakan`.`id_akun`,
			`akun`.`nama`');
			$this->db->from('invoice');
			$this->db->join('invoice_detail', '`invoice`.`id_invoice` = `invoice_detail`.`id_invoice`');
			$this->db->join('jenis_cetakan', '`invoice_detail`.`jenis_cetakan` = `jenis_cetakan`.`id_jenis`');
			$this->db->join('akun', '`jenis_cetakan`.`id_akun` = `akun`.`id_akun`');
			$this->db->where('invoice_detail.id_invoice', $id);
			$this->db->group_by(['invoice_detail.id_invoice','`jenis_cetakan`.`id_akun`']);
			return $this->db->get();
		}
		
		public function kas_detail($id)
		{
			$this->db->select('*');
			$this->db->from('kas_keluar_detail');
			$this->db->where('id_kas', $id);
			// $this->db->group_by('jurnal_detail.id_jurnal');
			return $this->db->get();
		}
		
		public function pembelian_detail($id)
		{
			$this->db->select('  `item_pembelian`.`id_akun`,
			`pembelian_detail`.`jumlah`,
			`pembelian_detail`.`harga`,
			`pembelian_detail`.`keterangan`');
			$this->db->from('pembelian_detail');
			$this->db->join('item_pembelian', '`item_pembelian`.`id` = `pembelian_detail`.`id_bahan`');
			$this->db->where('id_pembelian', $id);
			// $this->db->group_by('jurnal_detail.id_jurnal');
			return $this->db->get();
		}
		public function cek_count($id){
			return $this->db->select('COUNT(id) AS `total`')
            ->from('bayar_invoice_detail')
            ->where('id_invoice',$id)
            ->get()
            ->row()->total;
		}
		
		public function cek_bayar($id){
			return $this->db->select('`bayar_invoice_detail`.`id`,
			`bayar_invoice_detail`.`jml_bayar`,
			`bayar_invoice_detail`.`rekap`,
			`bayar_invoice_detail`.`id_sub_bayar`')
            ->from('bayar_invoice_detail')
            ->where('id_invoice',$id)
            ->where('rekap','N')
            ->get();
		}
		
		public function cek_bayar_lunas($id){
			return $this->db->select('`bayar_invoice_detail`.`id`,
			`bayar_invoice_detail`.`jml_bayar`,
			`bayar_invoice_detail`.`rekap`,
			`bayar_invoice_detail`.`id_sub_bayar`')
            ->from('bayar_invoice_detail')
            ->where('id_invoice',$id)
            ->where('rekap','Y')
            ->get();
		}
		
		public function cek_bayar_byid($id){
			return $this->db->select('SUM(`bayar_invoice_detail`.`jml_bayar`) AS `total`,
			`bayar_invoice_detail`.`jml_bayar`,
			`bayar_invoice_detail`.`id_sub_bayar`')
            ->from('bayar_invoice_detail')
            ->where('id_invoice',$id)
            ->get()
            ->row();
		}
		public function sumBayar($bulan,$tahun){
			return $this->db->select('SUM(`bayar_invoice_detail`.`jml_bayar`) AS `total`')
            ->from('bayar_invoice_detail')
            ->where('month(bayar_invoice_detail.tgl_bayar)',$bulan)
            ->where('year(bayar_invoice_detail.tgl_bayar)',$tahun)
            ->get()
            ->row()->total;
		}
		
		public function insertJurnal($data){
            return $this->db->insert($this->table,$data);
		}
		
		public function input_jurnal($params = array()){
			// dump($params);
			if(array_key_exists("jurnal", $params)){
				$cek_count = $params["jurnal"]["cek_count"];
				$id_transaksi 	= $params["jurnal"]["id_transaksi"];
				$nama 	    	= $params["jurnal"]["nama"];
				if($cek_count > 1){
					$catatan =  "BAYAR ORDER NO#".$id_transaksi.' - '.$nama;
					}else{
					$catatan =  "ORDER NO#".$id_transaksi.' - '.$nama;
				}
				
				
				$id_invoice 	= $params["jurnal"]["id_invoice"];
				$lunas 		    = $params["jurnal"]["cek_lunas"];
				$jml_bayar 	    = $params["jurnal"]["jml_bayar"];
				 
				$total_order	=  $this->sum_order($id_invoice);
				$sisa           = $total_order - $jml_bayar;
				$id_akun 	    = $params["jurnal"]["id_akun"];
				$diskon_harga   = $params["jurnal"]["diskon_harga"];
				$diskon 		= $params["jurnal"]["diskon"];
				$status 		= $params["jurnal"]["status"];
				$akun_detail    =  $this->akun_detail($id_invoice)->result();
				$total_bayar = $this->cek_bayar_byid($id_invoice)->total;
				$pajak 			= $params["jurnal"]["pajak"];
				$total_pajak	= $params["jurnal"]["total_pajak"];
				if(empty($diskon) AND empty($pajak)){
					if($jml_bayar > 0 AND $lunas==true AND $status=='baru')
					{
						$catatan =  "ORDER NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						
						$input_jurnal_debet = array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun,
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $jml_bayar, 
						);
						$this->db->insert('jurnal_detail', $input_jurnal_debet);
						foreach($akun_detail AS $row)
						{
							$input_jurnal_kredit = array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $row->id_akun,
							'tipe_kas'			=> 0,
							'id_perkiraan'		=> 2, 
							'nilai'				=> $row->total
							);
							$this->db->insert('jurnal_detail', $input_jurnal_kredit);
						}
						
						$this->db->update('invoice', ["lunas" => 1], ["id_invoice" => $id_invoice]);
					}
					//input jurnal jika lunas
					if($jml_bayar > 0 AND $lunas==true AND $cek_count == 1 AND $status=='simpan')
					{
						$catatan =  "PELUNASAN ORDER NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						
						$input_jurnal = array(
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun,
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $jml_bayar, 
						),
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> 5,
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 2, 
						'nilai'				=> $jml_bayar, 
						)
						);
						$this->db->insert_batch('jurnal_detail', $input_jurnal);
						$this->db->update('invoice', ["lunas" => 1], ["id_invoice" => $id_invoice]);
					}
					
					//input jurnal untuk pelunasan
					if($jml_bayar > 0 AND $lunas==true AND $cek_count > 1 AND $status=='simpan')
					{
						$catatan =  "PELUNASAN ORDER NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						
						$total_kas_dp = $total_bayar - $jml_bayar;
						// debit pada kas tunai
						$input_jurnal = array(array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun,
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $total_order, 
						),
						
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun,//$this->get_akun(8),
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 2, 
						'nilai'				=> $total_kas_dp, 
						), 
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(6),
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 2, 
						'nilai'				=> $jml_bayar, 
						),
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(4),
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $total_order, 
						));
						$this->db->insert_batch('jurnal_detail', $input_jurnal);
						
						foreach($akun_detail AS $row)
						{
							$input_jurnal_kredit = array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $row->id_akun,
							'tipe_kas'			=> 0,
							'id_perkiraan'		=> 2, 
							'nilai'				=> $row->total
							);
							$this->db->insert('jurnal_detail', $input_jurnal_kredit);
						}
						
						$this->db->update('invoice', ["lunas" => 1], ["id_invoice" => $id_invoice]);
					}
					//input jurnal jika dp untuk transaksi baru
					if($jml_bayar > 0 AND $lunas==false AND $cek_count ==1 AND $status=='baru'){ 
						$catatan =  "ORDER NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						
						//debit pada kas tunai
						$input_jurnal = array(array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun, //AKUN KAS DP
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $jml_bayar, 
						),
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(6), //AKUN PIUTANG
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $sisa, 
						),
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(4), //AKUN KEWAJIBAN
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 2, 
						'nilai'				=> $total_order, 
						));
						$this->db->insert_batch('jurnal_detail', $input_jurnal);
					}
					//input jurnal untuk pembayaran piutang
					if($jml_bayar > 0 AND $lunas==false AND $cek_count == 1 AND $status=='simpan'){ 
						
						$catatan =  "ORDER NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						
						//debit pada kas tunai
						$input_jurnal = array(array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun, //AKUN KAS DP
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $jml_bayar, 
						),
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(6), //AKUN PIUTANG
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $sisa, 
						),
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(4), //AKUN KEWAJIBAN
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 2, 
						'nilai'				=> $total_order, 
						));
						$this->db->insert_batch('jurnal_detail', $input_jurnal);
					}
					
					//input jurnal untuk pembayaran piutang
					if($jml_bayar > 0 AND $lunas==false AND $cek_count > 1 AND $status=='simpan'){ 
						
						$catatan =  "BAYAR PIUTANG NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						//debit pada kas tunai
						$input_jurnal = array(array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $id_akun, //AKUN KAS DP
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $jml_bayar, 
						),
						
						array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(6), //AKUN PIUTANG
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 2, 
						'nilai'				=> $jml_bayar, 
						));
						$this->db->insert_batch('jurnal_detail', $input_jurnal);
					}
					
					if($jml_bayar == 0 AND $lunas==false AND $status=='baru'){ 
						
						$catatan =  "PIUTANG NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
						$this->db->insert('jurnal', $data);
						$jurnal_id 	    = $this->db->insert_id();
						$input_jurnal_debet = array(
						'id_jurnal' 		=> $jurnal_id,
						'id_akun'			=> $this->get_akun(6),
						'tipe_kas'			=> 1,
						'id_perkiraan'		=> 1, 
						'nilai'				=> $total_order, 
						);
						$this->db->insert('jurnal_detail', $input_jurnal_debet);
						foreach($akun_detail AS $row)
						{
							$input_jurnal_kredit = array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $row->id_akun,
							'tipe_kas'			=> 0,
							'id_perkiraan'		=> 2, 
							'nilai'				=> $row->total
							);
							$this->db->insert('jurnal_detail', $input_jurnal_kredit);
						}
					}
				}
				
				if($diskon_harga ==1)
				{
					if($jml_bayar > 0)
					{
						if($jml_bayar > 0 AND $lunas==true AND $cek_count == 1 AND $status=='simpan')
						{
							$catatan =  "PELUNASAN ORDER NO#".$id_transaksi.' - '.$nama;
							$data = [
							"no_trans" 		=> $params["jurnal"]["no_trans"],
							"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
							"keterangan" 	=> $catatan,
							"bukti" 	    => $params["jurnal"]["lampiran"],
							"id_user" 		=> $params["jurnal"]["id_user"]
							];
							
							$this->db->insert('jurnal', $data);
							$jurnal_id 	    = $this->db->insert_id();
							
							$input_jurnal = array(
							array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $id_akun,
							'tipe_kas'			=> 1,
							'id_perkiraan'		=> 1, 
							'nilai'				=> $jml_bayar, 
							),
							array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> 5,
							'tipe_kas'			=> 1,
							'id_perkiraan'		=> 2, 
							'nilai'				=> $total_order, 
							),
							array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $this->get_akun(5),
							'tipe_kas'			=> 1,
							'id_perkiraan'		=> 1, 
							'nilai'				=> $diskon, 
							));
							$this->db->insert_batch('jurnal_detail', $input_jurnal);
							$this->db->update('invoice', ["lunas" => 1], ["id_invoice" => $id_invoice]);
							// dump($input_jurnal);
						}
						if($jml_bayar > 0 AND $lunas==true AND $cek_count == 1 AND $status=='baru')
						{
							$catatan =  "ORDER NO#".$id_transaksi.' - '.$nama;
							$data = [
							"no_trans" 		=> $params["jurnal"]["no_trans"],
							"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
							"keterangan" 	=> $catatan,
							"bukti" 	    => $params["jurnal"]["lampiran"],
							"id_user" 		=> $params["jurnal"]["id_user"]
							];
							
							$this->db->insert('jurnal', $data);
							$jurnal_id 	    = $this->db->insert_id();
							$input_jurnal_debet = array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $this->get_akun(6),
							'tipe_kas'			=> 1,
							'id_perkiraan'		=> 1, 
							'nilai'				=> $total_order, 
							);
							$this->db->insert('jurnal_detail', $input_jurnal_debet);
							
							
							//debit pada kas tunai
							$input_jurnal = array(array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> 1,
							'tipe_kas'			=> 1,
							'id_perkiraan'		=> 1, 
							'nilai'				=> $jml_bayar, 
							),
							
							array(
							'id_jurnal' 		=> $jurnal_id,
							'id_akun'			=> $this->get_akun(5),
							'tipe_kas'			=> 1,
							'id_perkiraan'		=> 1, 
							'nilai'				=> $diskon, 
							));
							foreach($akun_detail AS $row)
							{
								$input_jurnal_kredit = array(
								'id_jurnal' 		=> $jurnal_id,
								'id_akun'			=> $row->id_akun,
								'tipe_kas'			=> 0,
								'id_perkiraan'		=> 2, 
								'nilai'				=> $row->total
								);
								$this->db->insert('jurnal_detail', $input_jurnal_kredit);
							}
							$this->db->insert_batch('jurnal_detail', $input_jurnal);
							$this->db->update('invoice', ["lunas" => 1], ["id_invoice" => $id_invoice]);
						}
					}
				}
				
				if($pajak > 0)
				{
					if($jml_bayar > 0)
					{
						$catatan =  "ORDER NO#".$id_transaksi.' - '.$nama;
						$data = [
						"no_trans" 		=> $params["jurnal"]["no_trans"],
						"tgl"	 		=> $params["jurnal"]["tgl_transaksi"],
						"keterangan" 	=> $catatan,
						"bukti" 	    => $params["jurnal"]["lampiran"],
						"id_user" 		=> $params["jurnal"]["id_user"]
						];
						
					$this->db->insert('jurnal', $data);
					$jurnal_id 	    = $this->db->insert_id();
					
					$this->db->update('invoice', ["lunas" => 1], ["id_invoice" => $id_invoice]);
					//debit pada kas tunai
					$input_jurnal = array(array(
					'id_jurnal' 		=> $jurnal_id,
					'id_akun'			=> $id_akun,
					'tipe_kas'			=> 1,
					'id_perkiraan'		=> 1, 
					'nilai'				=> $jml_bayar - $total_pajak, 
					'catatan_jurnal' 	=> '', 
					),
					array(
					'id_jurnal' 		=> $jurnal_id,
					'id_akun'			=> 15,
					'tipe_kas'			=> 1,
					'id_perkiraan'		=> 2, 
					'nilai'				=> $jml_bayar, 
					'catatan_jurnal' 	=> '', 
					),
					
					array(
					'id_jurnal' 		=> $jurnal_id,
					'id_akun'			=> 25,
					'tipe_kas'			=> 1,
					'id_perkiraan'		=> 1, 
					'nilai'				=> $total_pajak, 
					'catatan_jurnal' 	=> '', 
					));
					$this->db->insert_batch('jurnal_detail', $input_jurnal);
					}
				}
				
			}
		}
		// menampilkan data berdasarkan id
		public function getIdAkunKasById($id)
		{
			$query = $this->db->get_where('set_account_kas', ['id_akun' => $id]);
			$result = ($query->num_rows() > 0)?$query->row()->id_akun:0; 
			return $result;
		}
		// menampilkan data berdasarkan id
		public function getTypeKasByIdAkun($id)
		{
			$query = $this->db->get_where('akun', ['id_akun' => $id]);
			$result = ($query->num_rows() > 0)?$query->row()->id_perkiraan:0; 
			return $result;
		}
		 
		public function get_akun($id)
		{
			return $this->db->where('id',$id)->get('jenis_bayar')->row()->id_akun;
		}
		
		public function hapus_jurnal($reff){
			return $this->db->where('keterangan',$reff)->delete('jurnal');
		}
		
		public function deleteJurnal($id){
			return $this->db->where('id_transaksi',$id)->delete($this->table);
		}
		
		public function validate(){
			$rules = $this->getValidationRules();
			$this->form_validation->set_rules($rules);
			$this->form_validation->set_error_delimiters('<span class="text-danger" style="font-size:14px">','</span>');
			return $this->form_validation->run();
		}
		public function getValidationRules(){
			return [
			[
			'field'=>'tgl_transaksi',
			'label'=>'Tanggal Transaksi',
			'rules'=>'trim|required'
			],
			[
			'field'=>'no_reff',
			'label'=>'Nama Akun',
			'rules'=>'trim|required'
			],
			[
			'field'=>'jenis_saldo',
			'label'=>'Jenis Saldo',
			'rules'=>'trim|required'
			],
			[
			'field'=>'saldo',
			'label'=>'Saldo',
			'rules'=>'trim|required|numeric'
			],
			];
		}
	}																																																							