<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="csrf-token" content="{{ csrf_token() }}">
	<title>{{ env("APP_NAME") }}</title>

	<link href="https://fonts.googleapis.com/css?family=Roboto:400,300,100,500,700,900" rel="stylesheet" type="text/css">
	<link href="{{ url("css/icons/icomoon/styles.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("css/icons/fontawesome/styles.min.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("css/bootstrap.min.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("css/core.min.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("css/components.min.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("css/colors.min.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("dist/sweetalert2/sweetalert2.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("selectize/css/selectize.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("selectize/css/selectize.bootstrap3.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("treegrid/css/jquery.treegrid.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("dist/jquery.loading/jquery.loading.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("dist/datepicker/css/bootstrap-datepicker.css")}}" rel="stylesheet" type="text/css">

	<link href="{{ url("dist/bootstrap-timepicker/css/bootstrap-timepicker.css")}}" rel="stylesheet" type="text/css">
	<link href="{{ url("css/custom.css")}}" rel="stylesheet" type="text/css">
	<!-- <script type="text/javascript" src="{{ url('js/dependencies/rsvp-3.1.0.min.js')}}"></script> -->
	<!-- <script type="text/javascript" src="{{ url('js/dependencies/sha-256.min.js') }}"></script> -->
	<!-- <script type="text/javascript" src="{{ url('js/qz-tray.js') }}"></script> -->

	<style type="text/css">
		input[type=number]::-webkit-inner-spin-button, 
		input[type=number]::-webkit-outer-spin-button { 
		  -webkit-appearance: none; 
		  margin: 0; 
		}
	</style>
	
	<script src="{{ url("js/core/libraries/jquery.min.js")}}"></script>
	<script src="{{ url("js/plugins/tables/datatables/datatables.min.js")}}"></script>
	<script src="{{ url("js/plugins/tables/datatables/extensions/buttons.min.js")}}"></script>
	{{-- <script src="{{ url("js/plugins/tables/datatables/extensions/responsive.min.js")}}"></script> --}}
	<script src="{{ url("js/plugins/loaders/pace.min.js")}}"></script>
	<script src="{{ url("js/core/libraries/bootstrap.min.js")}}"></script>
	<script src="{{ url("js/plugins/loaders/blockui.min.js")}}"></script>
	<script src="{{ url("dist/sweetalert2/sweetalert2.js")}}"></script>
	<script src="{{ url("/js/core/libraries/jquery_ui/interactions.min.js")}}"></script>
	<script src="{{ url("js/plugins/forms/selects/select2.min.js")}}"></script>
	<script src="{{ url("js/plugins/forms/styling/uniform.min.js")}}"></script>
	<script src="{{ asset("js/core/libraries/jasny_bootstrap.min.js")}}"></script>
	<script src="{{ url("js/plugins/notifications/pnotify.min.js")}}"></script>
	<script src="{{ url("selectize/js/standalone/selectize.min.js")}}"></script>
	<script type="text/javascript" src="{{ url("treegrid/js/jquery.treegrid.js")}}"></script>
	<script src="{{ url("dist/jquery.loading/jquery.loading.js")}}"></script>
	<script src="{{ url("js/plugins/numeral/numeral.js")}}"></script>
	<script src="{{ url("js/plugins/forms/validation/validate.min.js")}}"></script>
	<script src="{{ url("dist/bootstrap-timepicker/js/bootstrap-timepicker.js")}}"></script>

	@section('token')
		
	@endsection

	<script src="{{ url("/js/plugins/accountingjs/accounting.min.js")}}"></script>
	<script type="text/javascript">
		$(document).ready(function(){

			accounting.settings = {
				currency: {
					symbol : "Rp",   // default currency symbol is '$'
					format: { pos : "%s%v", neg : "( %s%v )", zero : "%s%v"}, // controls output: %s = symbol, %v = value/number (can be object: see below)
					decimal : ",",  // decimal point separator
					thousand: ".",  // thousands separator
					precision : 2   // decimal places
				},
				number: {
					precision : 2,  // default precision on numbers is 0
					thousand: ".",
					decimal : ","
				}
			}

			    numeral.register('locale', 'id', {
		        delimiters: {
		            thousands: '.',
		            decimal: ','
		        },
		        abbreviations: {
		            thousand: 'k',
		            million: 'm',
		            billion: 'b',
		            trillion: 't'
		        },
		        ordinal : function (number) {
		            return number === 1 ? 'er' : 'ème';
		        },
		        currency: {
		            symbol: '€'
		        }
		    });

		    // switch between locales
		    numeral.locale('id');

		})
	</script>

</head>
<body class="navbar-top sidebar-xs">

	<!-- Main navbar -->
	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-header">
			<a class="navbar-brand" href="{{ url('') }}">{{ env("APP_NAME")}}</a>

			<ul class="nav navbar-nav visible-xs-block">
				<li><a data-toggle="collapse" data-target="#navbar-mobile"><i class="icon-tree5"></i></a></li>
				<li><a class="sidebar-mobile-main-toggle"><i class="icon-paragraph-justify3"></i></a></li>
				@yield("menu_bar")
			</ul>
		</div>

		<div class="navbar-collapse collapse" id="navbar-mobile">
			<ul class="nav navbar-nav">
				<li><a class="sidebar-control sidebar-main-toggle hidden-xs"><i class="icon-paragraph-justify3"></i></a></li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
			<!------ NOTIFICATION MONITORING PERSEDIAAN ----------------------------------------------------------------------->
				<li class="dropdown" id="notif_tombol">
					<a class="dropdown-toggle" data-toggle="dropdown">
						<i class="icon-bubbles4"></i>
						<span class="visible-xs-inline-block position-right">Messages</span>
						<span class="badge bg-warning-400" id="notif_idnilai"></span>
					</a>
					<div class="dropdown-menu dropdown-content width-350">
						<div class="dropdown-content-heading">
							Messages
							<ul class="icons-list">
								<li><a href="#"><i class="icon-compose"></i></a></li>
							</ul>
						</div>
						<ul class="media-list dropdown-content-body">
							<li class="media">
								<div class="media-left" id="notif_idgambar">
									
								</div>
								<div class="media-body" id="notif_idbarang">
									
								</div>
							</li>
						</ul>
						<div class="dropdown-content-footer">
							<a href="#" id="notif_footer" data-popup="tooltip" title="" data-original-title="All messages"><i class="icon-menu display-block"></i></a>
						</div>
					</div>
				</li>
				<!------ END NOTIFICATION MONITORING PERSEDIAAN ----------------------------------------------------------------------->
				<li class="dropdown dropdown-user">
					<a class="dropdown-toggle" data-toggle="dropdown">
						@php if(Session::get('foto') == '' || Session::get('foto') == null){ @endphp
						<img src="{{ url("/images/placeholders/placeholder.jpg") }}" alt="">
						@php }else{ @endphp
						<img src="{{ url(Session::get('foto')) }}" alt="">
						@php } @endphp
						<span>{{Session::get('nama')}}</span>
						<i class="caret"></i>
					</a>

					<ul class="dropdown-menu dropdown-menu-right">
						<!-- <li><a href="#"><i class="icon-user-plus"></i>Profil</a></li>
						<li><a href="{{url('admin/logout')}}"><i class="icon-switch2"></i> Logout</a></li> -->
						<!-- @php if(Session::get('kode_group') != 3){ @endphp -->
						<!-- @php } @endphp -->
						<li><a href="{{url('myprofil/'.Session::get('kode_user'))}}"><i class="icon-user-plus"></i>Profil</a></li>
						<li><a href="{{url('logout')}}"><i class="icon-switch2"></i> Logout</a></li>
					</ul>
				</li>
			</ul>
		</div>
	</div>

	<div class="page-container">

		<!-- Page content -->
		<div class="page-content">

			<!-- Main sidebar -->
			<div class="sidebar sidebar-main">
				<div class="sidebar-content">
					<!-- Main navigation -->
					<div class="sidebar-category sidebar-category-visible">
						<div class="category-content no-padding">
							@php
							function createTreeView($array, $currentParent, $currLevel = 0, $prevLevel = -1) {
								foreach ($array as $categoryId => $category) {
									if ($currentParent == $category['parent_id']) {
										if ($currLevel == $prevLevel) echo " </li> ";
									echo '<li><a href="'.url($category['link']).'"><i class="'.$category['icon'].'">
									</i><span>'.$category['name'].'</span></a>';
									if ($currLevel > $prevLevel) { $prevLevel = $currLevel; }
									$currLevel++; 
									createTreeViewSub ($array, $categoryId, $currLevel, $prevLevel);
									$currLevel--;               
    							}   
    						}
    						if ($currLevel == $prevLevel) echo " </li>";
    						}
    						function createTreeViewSub($array, $currentParent, $currLevel = 0, $prevLevel = -1) {
								foreach ($array as $categoryId => $category) {
									if ($currentParent == $category['parent_id']) {                       
    								if ($currLevel > $prevLevel) echo " <ul>"; 
										if ($currLevel == $prevLevel) echo " </li> ";
									echo '<li><a href="'.url($category['link']).'">'.$category['name'].'</a>';
									if ($currLevel > $prevLevel) { $prevLevel = $currLevel; }
									$currLevel++; 
									createTreeViewSub ($array, $categoryId, $currLevel, $prevLevel);
									$currLevel--;               
    							}   
    						}
    						if ($currLevel == $prevLevel) echo "</li></ul>";
    						}

							$kode_group= session('kode_group');
    						$sql = DB::select("SELECT  a.* FROM tb_menu a
                        			JOIN tb_role b ON a.kode_menu=b.kode_menu WHERE kode_group='$kode_group' AND status_role='1'  AND active='1' order by sort_menu asc");
    						$arrayCategories = array();
    						foreach($sql as $row){
    							$arrayCategories[$row->kode_menu] = array("parent_id" => $row->parent_menu, 
    																		"name" => $row->nama_menu,
    																		"link" => $row->link_menu,
    																		"icon" => $row->icon_menu);
    						}
							@endphp
							<ul class='navigation navigation-main navigation-accordion'>
								<li><a href="">&nbsp;</a></li>
							@php
							if(count($sql) != 0){
							createTreeView($arrayCategories, 0);
							}
							@endphp
						</ul>

						</div>
					</div>
				</div>
			</div>
			<script type="text/javascript">
				$.extend( $.fn.dataTable.defaults, {
			        autoWidth: false,
			        columnDefs: [{ 
			            orderable: false,
			            width: '100px',
			        }],
			        dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
			        language: {
			            search: '<span>Filter:</span> _INPUT_',
			            searchPlaceholder: 'Type to filter...',
			            lengthMenu: '<span>Show:</span> _MENU_',
			            paginate: { 'first': 'First', 'last': 'Last', 'next': $('html').attr('dir') == 'rtl' ? '&larr;' : '&rarr;', 'previous': $('html').attr('dir') == 'rtl' ? '&rarr;' : '&larr;' }
			        },
			        drawCallback: function () {
			            $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
			        },
			        preDrawCallback: function() {
			            $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
			        }
			    });
			</script>
			<!-- Main content -->
			<div class="content-wrapper">
				
			@yield("content")

			</div>
			<!-- /main content -->

		</div>
		<!-- /page content -->

	</div>
	<!-- /page container -->
	<!-- Core JS files -->
	<!-- /core JS files -->

	<!-- Theme JS files -->
	<script src="{{ url("/js/plugins/visualization/d3/d3.min.js")}}"></script>
	<script src="{{ url("/js/plugins/visualization/d3/d3_tooltip.js")}}"></script>
	<script src="{{ url("/js/plugins/forms/styling/switchery.min.js")}}"></script>
	<script src="{{ url("/js/plugins/forms/selects/bootstrap_multiselect.js")}}"></script>
	<script src="{{ url("/js/plugins/ui/moment/moment.min.js")}}"></script>
	<script src="{{ url("/js/plugins/pickers/datepicker.js")}}"></script>
	<script src="{{ url("/js/plugins/ui/nicescroll.min.js")}}"></script>
	{{-- <script src="{{ url("dist/datepicker/js/bootstrap-datepicker.js")}}"></script> --}}
	@yield("js_script")

	

	<script src="{{ url("/js/app.js")}}"></script>
	<script src="{{ url("/js/demo_pages/layout_fixed_custom.js")}}"></script>
	<script src="{{ url("/js/custom.js")}}"></script>
	
	
	
	<!-- /theme JS files -->
<style type="text/css">
	.right{
		text-align: right;
	}	

	.content {
	    padding: 0 20px 20px 20px;
	}
</style>
<script type="text/javascript">
	$(document).ready(function(){	
		// CheckBox
		$(".styled").uniform();
		
		$('.selectize').selectize({
		    create: true,
		    sortField: 'text'
		});

		$(".set_datepicker").datepicker({
			format : 'dd/mm/yyyy',
			autoclose : true,
			zIndexOffset : 99999,
		});
		
		$('.datatable-basic').DataTable();

		$('form').on('focus', 'input[type=number]', function (e) {
		  $(this).on('wheel.disableScroll', function (e) {
		    e.preventDefault()
		  })
		})
		$('form').on('blur', 'input[type=number]', function (e) {
		  $(this).off('wheel.disableScroll')
		})

		var date = new Date();
		var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
		var year = new Date(date.getFullYear())

		$('.datepicker').datepicker({
			format : 'dd-mm-yyyy',
			setDate: new Date(),
			autoclose: true,
			clearBtn: true,
		});

		$('.date_awal').datepicker({
			format : 'dd-mm-yyyy',
			setDate: new Date(),
			autoclose: true,
			clearBtn: true,
		});

		$('.date_akhir').datepicker({
			format : 'dd-mm-yyyy',
			setDate: new Date(),
			autoclose: true,
			clearBtn: true,
		});

		$('.date_tahun').datepicker({
			format : 'yyyy',
			setDate: new Date(),
			viewMode: 'years',
			minViewMode: 'years',
			autoclose: true,
			clearBtn: true,
		});

		$(".date_awal").on("changeDate", function (e) {
	      $(".date_akhir").datepicker("setStartDate", e.date);
	    });

	    $(".date_akhir").on("changeDate", function (e) {
	      $(".date_awal").datepicker("setEndDate", e.date);
	    });

	    /*get_tt_menu();*/
		
	})

	function showModal(selector) {
		$(selector).modal({
			keyboard : false,
			backdrop : false,
		});
	}

	function hideModal(selector) {
		$(selector).modal("hide");
	}

	// Read a page's GET URL variables and return them as an associative array.
	function getUrlParams()
	{
	 var vars = {};
	    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
	        vars[key] = value;
	    });
	    return vars;

	}

	function inputMask(selector, currency="Rp")
	{
		accounting.settings = {
			currency: {
			symbol : currency,   // default currency symbol is '$'
			format: { pos : "%s%v"}, // controls output: %s = symbol, %v = value/number (can be object: see below)
			decimal : ",",  // decimal point separator
			thousand: ".",  // thousands separator
			precision : 0   // decimal places
			},
			number: {
				precision : 0,  // default precision on numbers is 0
				thousand: ".",
				decimal : ","
			}
		}

		var data = selector.val().replace("Rp", "").replace(".", "");
		if(data==""){
			data = 0;
		}
		console.log(accounting.formatMoney(data));
		return selector.val(accounting.formatMoney(data));
	}

	function formatRupiah(angka, prefix='Rp')
	{
	    if(prefix!=''){
	    	angka = angka.replace(prefix + "0", "");
	    }
	    var number_string = angka.replace(/[^,\d]/g, '').toString();

	    var split = number_string.split(','),
	      sisa  = split[0].length % 3,
	      rupiah  = split[0].substr(0, sisa),
	      ribuan  = split[0].substr(sisa).match(/\d{3}/gi);
	      
	    if (ribuan) {
	      separator = sisa ? '.' : '';
	      rupiah += separator + ribuan.join('.');
	    }

	    if (number_string == "") {
	    	return prefix + "0";
	    } else {
	    	rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
	    	return prefix == undefined ? rupiah : (rupiah ? prefix + rupiah : '');
	    }
	}

	function isNumberKey(evt) {
	    var charCode = (evt.which) ? evt.which : evt.keyCode;
	    if (charCode > 31 && (charCode < 48 || charCode > 57))
	        return false;
	    return true;
	}
</script>

</body>
</html>
