<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class treemenu extends MY_Controller {
	
	function __construct()
	{
		parent::__construct();
		
		$this->modul="treemenu";
		$view="treemenu2";
	}
	
	public function index()	{
		// $this->load->view($this->modul.'/treemenu2');		
		// $this->load->view($this->modul.'/'.$this->modul.'.cjs.php');
	}
	
	function getTreeData(){
		if ($this->session->userdata('grup') == "ADM"){
			echo '
		[{  
			"text":"Master Data",  
			"state":"closed",  
			"children":[{
				"text":"Master Company",
				"state":"closed",  
				"children":[{  
						"text":"<a href=\"'.site_url('company').'\" target=\"content\">All Company</a>"
					},{ 			 
						"text":"<a href=\"'.site_url('company_supplier').'\" target=\"content\">Supplier</a>"
					},{ 			 
						"text":"<a href=\"'.site_url('company_customer').'\" target=\"content\">Customer</a>"
					}
				]
			},{
			"text":"<a href=\"'.site_url('bahanbaku').'\" target=\"content\">Item Master</a>"
			},{
				"text":"<a href=\"'.site_url('line').'\" target=\"content\">Production Line</a>"
			},{  
				"text":"<a href=\"'.site_url('matcons').'\" target=\"content\">BOM</a>"
			},{  
				"text":"<a href=\"'.site_url('uplbom').'\" target=\"content\">Upload BOM</a>"
			},{  
				"text":"<a href=\"'.site_url('matcons_wip').'\" target=\"content\">BOM WIP</a>"
			},{  
				"text":"<a href=\"'.site_url('uplbom_wip').'\" target=\"content\">Upload BOM WIP</a>"
			}]
		},{  
			"id":1,  
			"text":"Transaction",
				"state":"closed",  
				"children":[{  
						"text":"<a href=\"'.site_url('so').'\" target=\"content\">Sales Order</a>"
				},{  
						"text":"<a href=\"'.site_url('uplso').'\" target=\"content\">Upload Sales Order</a>"
				},{ 			 
						"text":"<a href=\"'.site_url('po').'\" target=\"content\">Purchase Order</a>"
				},{  
						"text":"<a href=\"'.site_url('uplpo').'\" target=\"content\">Upload Purchase Order</a>"
				},{
						"text":"Incoming",
						"state":"closed",  
						"children":[{  
								"text":"<a href=\"'.site_url('matin').'\" target=\"content\">Material</a>"
							},{ 			 
								"text":"<a href=\"'.site_url('matinsk').'\" target=\"content\">Material Sub Kontrak</a>"
							},{ 			 
								"text":"<a href=\"'.site_url('fgin').'\" target=\"content\">Finished Goods</a>"
							},{ 
								"text":"<a href=\"'.site_url('macin').'\" target=\"content\">Machine and Equipment</a>"
							},{ 
								"text":"<a href=\"'.site_url('scin').'\" target=\"content\">Scrap</a>"							
							},{ 
								"text":"<a href=\"'.site_url('wipin').'\" target=\"content\">WIP</a>"							
							},{ 
								"text":"<a href=\"'.site_url('uplin').'\" target=\"content\">Upload</a>"
							}
						]
					},{	
						"text":"Outgoing",
						"state":"closed",  
						"children":[{  
								"text":"<a href=\"'.site_url('matout').'\" target=\"content\">Material</a>"
							},{ 			 
								"text":"<a href=\"'.site_url('fgout').'\" target=\"content\">Finished Goods</a>"				
							},{ 
								"text":"<a href=\"'.site_url('macout').'\" target=\"content\">Machine and Equipment</a>"				
							},{ 
								"text":"<a href=\"'.site_url('scout').'\" target=\"content\">Scrap</a>"						
							},{ 
								"text":"<a href=\"'.site_url('wipout').'\" target=\"content\">WIP</a>"							
							},{ 
								"text":"<a href=\"'.site_url('uplout').'\" target=\"content\">Upload</a>"
							}					
						]
					},{ 
						"text":"Stok Opname",
						"state":"closed",  
						"children":[{ 
								"text":"<a href=\"'.site_url('matopn').'\" target=\"content\">Material</a>"
							},{ 
								"text":"<a href=\"'.site_url('fgopn').'\" target=\"content\">Finished Goods</a>"
							},{ 
								"text":"<a href=\"'.site_url('macopn').'\" target=\"content\">Machine and Equipment</a>"
							},{ 
								"text":"<a href=\"'.site_url('scopn').'\" target=\"content\">Scrap</a>"
							},{ 
								"text":"<a href=\"'.site_url('wipopn').'\" target=\"content\">WIP</a>"
							},{ 
								"text":"<a href=\"'.site_url('uplopn').'\" target=\"content\">Upload</a>"
							}
						]
					},{ 			 
						"text":"<a href=\"'.site_url('ar').'\" target=\"content\">Account Receivable</a>"
					},{  
						"text":"<a href=\"'.site_url('arotm').'\" target=\"content\">Account Receivable (OTM)</a>"
					},{  
						"text":"<a href=\"'.site_url('ap').'\" target=\"content\">Account Payable</a>"
					}]
			},{  
				"text":"Report",  
				"state":"closed",  
				"children":[{ 
						"text":"Stock Card",
						"state":"closed",  
						"children":[{ 
								"text":"<a href=\"'.site_url('ksmat').'\" target=\"content\">Material</a>"
							},{ 
								"text":"<a href=\"'.site_url('ksfg').'\" target=\"content\">Finished Goods</a>"
							},{ 
								"text":"<a href=\"'.site_url('ksmac').'\" target=\"content\">Machine and Equipment</a>"
							},{ 
								"text":"<a href=\"'.site_url('kssc').'\" target=\"content\">Scrap</a>"
							},{ 
								"text":"<a href=\"'.site_url('kswip').'\" target=\"content\">WIP</a>"
							}
						]
					},{ 
						"text":"Mutation",
						"state":"closed",  
						"children":[{ 
								"text":"<a href=\"'.site_url('mumat').'\" target=\"content\">Material</a>"
							},{ 
								"text":"<a href=\"'.site_url('mufg').'\" target=\"content\">Finished Goods</a>"
							},{ 
								"text":"<a href=\"'.site_url('mumac').'\" target=\"content\">Machine and Equipment</a>"
							},{ 
								"text":"<a href=\"'.site_url('musc').'\" target=\"content\">Scrap</a>"
							},{ 
								"text":"<a href=\"'.site_url('muwip').'\" target=\"content\">WIP</a>"
							}
						]
					},{ 
						"text":"Bea Cukai Report",
						"state":"closed",  
						"children":[{ 
								"text":"<a href=\"'.site_url('brpt_masukrm').'\" target=\"content\">Pemasukan Barang</a>"
							},{ 
								"text":"<a href=\"'.site_url('brpt_keluarbarang').'\" target=\"content\">Pengeluaran Barang</a>"
							},{ 
								"text":"<a href=\"'.site_url('mumat').'\" target=\"content\">Mutasi Bahan Baku dan Bahan Penolong</a>"
							},{ 
								"text":"<a href=\"'.site_url('rmonwip').'\" target=\"content\">WIP</a>"
							},{ 
								"text":"<a href=\"'.site_url('mufg').'\" target=\"content\">Finished Goods</a>"
							},{ 
								"text":"<a href=\"'.site_url('musc').'\" target=\"content\">Scrap</a>"
							},{
								"text":"<a href=\"'.site_url('mumac').'\" target=\"content\">Machine and Equipment</a>"
							},{
								"text":"<a href=\"'.site_url('brpt_rekapbcp').'\" target=\"content\">Rekapitulasi BCP</a>"
							}
						]
					}
				]  
		},{  
			"text":"User Administration",  
			"state":"closed",  
			"children":[{  
				"text":"<a href=\"'.site_url('user').'\" target=\"content\">User</a>"
			},{  
				"text":"<a href=\"'.site_url('log').'\" target=\"content\">User Activity History</a>"
			}]
		},{ 
			"text":"<a href=\"'.site_url('main/logout').'\">Logout</a>"  
		}]

		';
		} else {
			echo '
		[{ 
			"text":"Bea Cukai Report",  
			"state":"closed",  
			"children":[{ 
							"text":"<a href=\"'.site_url('brpt_masukrm').'\" target=\"content\">Pemasukan Barang</a>"
						},{ 
							"text":"<a href=\"'.site_url('brpt_keluarbarang').'\" target=\"content\">Pengeluaran Barang</a>"
						},{ 
							"text":"<a href=\"'.site_url('mumat').'\" target=\"content\">Mutasi Bahan Baku dan Bahan Penolong</a>"
						},{ 
							"text":"<a href=\"'.site_url('rmonwip').'\" target=\"content\">WIP</a>"
						},{ 
							"text":"<a href=\"'.site_url('mufg').'\" target=\"content\">Finished Goods</a>"
						},{ 
							"text":"<a href=\"'.site_url('musc').'\" target=\"content\">Scrap</a>"
						},{
							"text":"<a href=\"'.site_url('mumac').'\" target=\"content\">Machine and Equipment</a>"
						},{
							"text":"<a href=\"'.site_url('brpt_rekapbcp').'\" target=\"content\">Rekapitulasi BCP</a>"
						}
			]  
	},{  
			"text":"User Administration",  
			"state":"closed",  
			"children":[{  
				"text":"<a href=\"'.site_url('user').'\" target=\"content\">User</a>"
			},{  
				"text":"<a href=\"'.site_url('log').'\" target=\"content\">User Activity History</a>"
			}]
		},{ 
			"text":"<a href=\"'.site_url('main/logout').'\">Logout</a>"  
		}]

		';
		}
		
	}
	function getTreeData2(){
		echo '[';
		if ($this->session->userdata('menu1') == "Master Data" && $this->session->userdata('l') == 1 ){
			echo '
			{  
				"text":"Master Data",  
				"state":"closed",  
				"children":
				[';
					if ($this->session->userdata('menu2') == "Master Perusahaan" && $this->session->userdata('l') == 1 ){
						echo'
						{
							"text":"Master Company",
							"state":"closed",  
							"children":
							[
								{"text":"<a href=\"'.site_url('company').'\" target=\"content\">All Company</a>"}
								,{"text":"<a href=\"'.site_url('company_supplier').'\" target=\"content\">Supplier</a>"}
								,{"text":"<a href=\"'.site_url('company_customer').'\" target=\"content\">Customer</a>"}
							]
						},';
					}else {echo '{"text":""},';}
					echo '
					{"text":"<a href=\"'.site_url('bahanbaku').'\" target=\"content\">Item Master</a>"}
					,{"text":"<a href=\"'.site_url('line').'\" target=\"content\">Production Line</a>"}
					,{"text":"<a href=\"'.site_url('matcons').'\" target=\"content\">BOM</a>"}
					,{"text":"<a href=\"'.site_url('uplbom').'\" target=\"content\">Upload BOM</a>"}
					,{"text":"<a href=\"'.site_url('matcons_wip').'\" target=\"content\">BOM WIP</a>"}
					,{"text":"<a href=\"'.site_url('uplbom_wip').'\" target=\"content\">Upload BOM WIP</a>"}
				]
			}';
		}
		echo '
		,{"text":"<a href=\"'.site_url('main/logout').'\">Logout</a>"}]';
	}
	function getTreeData3(){
		echo'
		<a href=\"'.site_url('main/logout').'\">Logout</a>';
	}
}