<?php
function menu_accounting()
{
	$res = array(
				array('menu' => 'master','logo' => 'Master Ball.png',
					'subUrl'=> array(
						array('menu' => 'Account', 'url' => 'mac', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'Setting-Account', 'url' => 'sac', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'sub','logo' => 'Master Ball.png',
							'subUrl'=> array(
								array('menu' => 'bank', 'url' => 'bank', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'customer', 'url' => 'master-cust', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'supplier', 'url' => 'master-supp', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'sales', 'url' => 'msales', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'kolektor', 'url' => 'mkolektor', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'lain-lain', 'url' => 'mlain', 'logo' => 'icon_computer_network_1.png'),
							),
						),
						array('menu' => 'gudang', 'url' => 'mgud', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'persediaan','logo' => 'Master Ball.png',
							'subUrl'=> array(
								array('menu' => 'kategori', 'url' => 'mkat', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'sub-kategori', 'url' => 'msubkat', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'inventori', 'url' => 'minv', 'logo' => 'icon_computer_network_1.png'),
							)
						),						
						array('menu' => 'Aktiva-tetap', 'url' => 'fix', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'currency', 'url' => 'kurs', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'exibit', 'url' => 'mex', 'logo' => 'icon_computer_network_1.png'),
					),
				),
				array('menu' => 'transaksi','logo' => 'Master Ball.png',
					'subUrl'=> array(
						array('menu' => 'Jurnal-Memo', 'url' => 'jum', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'kas','logo' => 'Master Ball.png',
							'subUrl'=> array(
								array('menu' => 'kas-masuk', 'url' => 'bkm', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'kas-keluar', 'url' => 'bkk', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'memorial', 'url' => 'kmm', 'logo' => 'icon_computer_network_1.png'),
							),
						),
						array('menu' => 'bank','logo' => 'Master Ball.png',
							'subUrl'=> array(
								array('menu' => 'bank-masuk', 'url' => 'bbm', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'bank-keluar', 'url' => 'bbk', 'logo' => 'icon_computer_network_1.png'),
							),
						),
						array('menu' => 'giro','logo' => 'Master Ball.png',
							'subUrl'=> array(
								array('menu' => 'giro-masuk', 'url' => 'bgm', 'logo' => 'icon_computer_network_1.png'),
								array('menu' => 'giro-keluar', 'url' => 'bgk', 'logo' => 'icon_computer_network_1.png'),
							),
						),
						array('menu' => 'Pelunasan-Piutang', 'url' => 'jpl', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'Pelunasan-Hutang', 'url' => 'jph', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'jurnal-penyusutan', 'url' => 'jps', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'jurnal-penutup', 'url' => 'jpn', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'posting-ulang', 'url' => 'post', 'logo' => 'icon_computer_network_1.png'),
					),
				),
				array('menu' => 'laporan-hutang','logo' => 'Master Ball.png',
					'subUrl'=> array(
						array('menu' => 'by-nota', 'url' => 'larn', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'aging-by-nota', 'url' => 'lara', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'aging-by-supplier', 'url' => 'larc', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'by-nota-belum-lunas', 'url' => 'larnbl', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'daftar-hutang', 'url' => 'lbbsp', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'posisi-hutang', 'url' => 'lbrs', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'sejarah-hutang', 'url' => 'lbbst', 'logo' => 'icon_computer_network_1.png'),
					),
				),
				array('menu' => 'laporan-piutang','logo' => 'Master Ball.png',
					'subUrl'=> array(
						array('menu' => 'by-nota', 'url' => 'lapn', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'aging-by-nota', 'url' => 'lapa', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'aging-by-customer', 'url' => 'lapc', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'by-nota-belum-lunas', 'url' => 'lapnbl', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'daftar-piutang', 'url' => 'lbbsp2', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'posisi-piutang', 'url' => 'lbrs2', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'sejarah-piutang', 'url' => 'lbbst2', 'logo' => 'icon_computer_network_1.png'),
					),
				),
				array('menu' => 'laporan-keuangan','logo' => 'Master Ball.png',
					'subUrl'=> array(
						array('menu' => 'kas-bank-harian', 'url' => 'lkh', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'detail-jurnal', 'url' => 'ldj', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'jurnal-tidak-ballance', 'url' => 'ltb', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'buku-besar-pembantu', 'url' => 'lbp', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'neraca-percobaan', 'url' => 'lnp', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'worksheet', 'url' => 'lnpw', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'laba-rugi-kotor', 'url' => 'llrk', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'laba-rugi', 'url' => 'llr', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'neraca-standart', 'url' => 'lnr', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'posisi-sub-account-lain', 'url' => 'lbrs3', 'logo' => 'icon_computer_network_1.png'),
					),
				),
				array('menu' => 'laporan-stok','logo' => 'Master Ball.png',
					'subUrl'=> array(
						array('menu' => 'posisi-stok', 'url' => 'lbrp2', 'logo' => 'icon_computer_network_1.png'),
						array('menu' => 'persediaan-tidak-laku', 'url' => 'lbtl', 'logo' => 'icon_computer_network_1.png'),
					),
				),
			);
	
		$jum = count($res);
		$eac = $jum - 2;
		$ecf = $jum - 1;
	
		$em = new PgSql;
		$sql = $em->addSelect("*");
		$sql = $em->getFrom('temah', 'a');
		$sql = $em->getWhere("hapus = 0");
		$sql = $em->getMultiShort('kode asc');
		$eks = $em->queryEks($sql);
		$det = $em->getFetchObject($eks);
		foreach($det as $row){
			if($row->ket == 'ACC'){
				$res[$eac]['subUrl'][] = array('menu' => strtolower($row->nama), 'url' => 'lext___'.$row->kode, 'logo' => 'icon_computer_network_1.png');
			}
		}
	
	return $res;
}

function logo_accounting()
{
	return 'lap-acc.png';
}

class SELECT_APP_ACCOUNTING
{
	public function PAPER()
	{
		$res['P'] = 'Potraid';
		$res['L'] = 'Landscape';
		
		return $res;
	}
	
	public function HARI()
	{
		$res['SENIN'] 	= 'SENIN';
		$res['SELASA'] 	= 'SELASA';
		$res['RABU'] 	= 'RABU';
		$res['KAMIS'] 	= 'KAMIS';
		$res['JUMAT'] 	= 'JUMAT';
		$res['SABTU'] 	= 'SABTU';
		$res['MINGGU'] 	= 'MINGGU';
		
		return $res;
	}
	
	public function GRUPAKUN()
	{
		$res['1'] = "AKTIVA";
		$res['2'] = "KEWAJIBAN";
		$res['3'] = "MODAL";
		$res['4'] = "PENDAPATAN";
		$res['5'] = "HPP";
		$res['6'] = "BIAYA";
		$res['7'] = "PENDAPATAN LAIN";
		$res['8'] = "BIAYA LAIN";
		$res['9'] = '-';
		
		return $res;
	}
	
	public function KASBANK()
	{
		$res['KAS'] = "KAS";
		$res['BANK'] = "BANK";
		$res['JURNAL'] = "JURNAL";
		
		return $res;
	}
	
	public function _STYLE()
	{
		$res['B'] 	= "BOLD";
		$res['U'] 	= "GARIS BAWAH";
		$res['BU'] 	= "BOLD GARIS BAWAH";
		
		return $res;
	}
	
	public function JENISACC()
	{
		$res['ACC'] = "ACCOUNTING";
		$res['CF'] 	= "CASH FLOW";
		
		return $res;
	}
	
	public function JENEXIBIT()
	{
		$res['STANDART'] 	= "STANDART";
		$res['SD'] 			= "SAMPAI DENGAN";
		$res['VS'] 			= "VS";
		
		return $res;
	}
	
	public function FIXASSET()
	{
		$res['110.01.01']	= "TANAH";
		$res['111.01.01']	= "BANGUNAN";
		$res['112.01.01']	= "KENDARAAN";
		$res['113.01.01']	= "INVENTARIS";
		
		return $res;
	}
	
	public function METODEPENYUSUTAN()
	{
		$res['STRAIGHTLINE']	= "STRAIGHTLINE";
		$res['DOUBLE DECLINING']= "DOUBLE DECLINING";
		
		return $res;
	}
	
	public function KASBANKSEL()
	{
		return array();
	}
	
	public function TF()
	{
		$res['T'] = 'True';
		$res['F'] = 'False';
		
		return $res;
	}
	
	public function LOKASI()
	{
		$res['JK'] = 'Jakarta';
		$res['GB'] = 'Gembong';
		$res['DH'] = 'Dharmahusada';
		$res['CT'] = 'Counter';
		
		return $res;
	}
	
	public function GUDANG()
	{
		return array();
	}
	
	public function JENIS_BAYAR()
	{
		$res['TUNAI'] 		= 'TUNAI';
		$res['CEK/GIRO'] 	= 'CEK/GIRO';
		$res['TRANSFER'] 	= 'TRANSFER';
		
		return $res;
	}
	
	public function EXTSTYLE()
	{
		$res['U'] 	= 'UNDERLINE';
		$res['B'] 	= 'BOLD';
		$res['BU'] 	= 'BOLD UNDERLINE';
		
		return $res;
	}
	
	public function CABANG()
	{
		return array();
	}
	
	public function KAS()
	{
		return array();
	}
	
	public function BANK()
	{
		return array();
	}
	
	public function BNK()
	{
		return array();
	}
	
	public function KASBNK()
	{
		return array();
	}
	
	public function PEMILIK()
	{
		$res['PERUSAHAAN'] 	= "PERUSAHAAN";
		$res['PRIBADI'] 	= "PRIBADI";
		
		return $res;
	}
}

class RumusReport
{
	public function setsaldoAcd($row)
	{
		return $row->awal + ($row->debet-$row->credit);
	}
	
	public function setpricelist($row)
	{
		return "<input type='text' size='13' id='".$row->kd_inv."' name='harga[".$row->kd_inv."]' class='decimal' value='".$row->harga."'>
				";
	}
	
	public function setdppBeli($row)
	{
		$kode = new Kode;
		$res  = $kode->totBertingkatPosting($row);
		return $res['dpp'];
	}
	
	public function settotBeli($row)
	{
		$kode = new Kode;
		$res  = $kode->totBertingkatPosting($row);
		return $res['tot'];
	}
	
	public function setppnBeli($row)
	{
		$kode = new Kode;
		$res  = $kode->totBertingkatPosting($row);
		return $res['ppn'];
	}
	
	public function idInv($id)
	{
		return str_ireplace("/", "_", str_ireplace("-", "_", $id));
	}
	
	public function set_cekAnalisa($row, $a, $no)
	{
		// if(empty($row->tgl_fp)){
			$id = $this->idInv($row->no_invoice);
			return '<input type="checkbox" id="'.$id.'" inv="'.$id.'" class="_cek _input ck_'.$no.'" name="cek['.$row->no_invoice.']">';
		// }
		return '';
	}
	
	public function set_nofp($row, $a, $no)
	{
		$id = $this->idInv($row->no_invoice);
		return '<input type="text" size="25" id="no_'.$id.'" class="fp _input pr_'.$no.' _copyFp" name="no_fp['.$row->no_invoice.']" value="'.$row->no_fp.'">';
		if(empty($row->tgl_fp)){
			$res='<input type="text" size="12" id="pr_'.$id.'" readonly disabled class="fp _prfp _input pr_'.$no.'" name="prefik['.$row->no_invoice.']" _no="'.$no.'">';
			$res.='&nbsp;<input type="text" size="8" id="no_'.$id.'" readonly disabled class="fp _nofp _input no_'.$no.'" name="no_fp['.$row->no_invoice.']" _no="'.$no.'">';
			return $res;
		}else{
		}
	}
	
	public function set_tglfp($row, $a, $no)
	{
		$id = $this->idInv($row->no_invoice);
		return '<input type="text" id="tgl_'.$id.'" class="fp _input tanggal _tgfp tg_'.$no.'" size="10" name="tgl_fp['.$row->no_invoice.']" value="'.$row->tgl_fp.'" _no="'.$no.'">';
	}
	
	public function set_stdfp($row, $a, $no)
	{
		$id = $this->idInv($row->no_invoice);
		
		if(empty($row->tgl_fp)){

			$res = '<select id="std_'.$id.'" disabled class="std _input _std std_'.$no.'" name="std['.$row->no_invoice.']"> 
					<option value="STD">STD
					<option value="SDHN">SDHN
				</select>';
		
			return $res;
		}else{
			return '<input type="text" size="4" id="std_'.$id.'" disabled class="std _input" name="std['.$row->no_invoice.']" value="'.$row->std.'">';
		}
		
	}
}