<!-- jQuery UI v1.13.0 -->
<script src="assets/AdminLTE-3.2.0/plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="assets/AdminLTE-3.2.0/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Select 2 -->
<script src="assets/plugin/select2-4.1.0-rc.0/js/select2.min.js"></script>
<!-- ChartJS -->
<script src="assets/AdminLTE-3.2.0/plugins/chart.js/Chart.min.js"></script>
<!-- Date Range Picker -->
<script src="assets/AdminLTE-3.2.0/plugins/moment/moment.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempus Dominus Bootstrap 4 -->
<script src="assets/AdminLTE-3.2.0/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- overlayScrollbars -->
<script src="assets/AdminLTE-3.2.0/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="assets/AdminLTE-3.2.0/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/jszip/jszip.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/pdfmake/pdfmake.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/pdfmake/vfs_fonts.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="assets/AdminLTE-3.2.0/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- SweetAlert2 -->
<script src="assets/AdminLTE-3.2.0/plugins/sweetalert2/sweetalert2.min.js"></script>

<!-- AdminLTE App -->
<script src="assets/AdminLTE-3.2.0/dist/js/adminlte.min.js"></script>

<!-- Page specific script -->
<script>
	$(function () {
		"use strict";

		<?php if ( $menu == 'dashboard' ) { ?>
			//-------------
			//- BAR CHART -
			//-------------
			// Get context with jQuery - using jQuery's .get() method.
			var barChartCanvas  = $( '#barChart' ).get( 0 ).getContext( '2d' );
			var barChartData    = {
				labels   : [ <?php echo $bar_labels; ?> ],
				datasets : [
					{
						label                : 'Sales',
						backgroundColor      : 'rgba(60,141,188,0.9)',
						borderColor          : 'rgba(60,141,188,0.8)',
						pointRadius          : false,
						pointColor           : '#3b8bba',
						pointStrokeColor     : 'rgba(60,141,188,1)',
						pointHighlightFill   : '#fff',
						pointHighlightStroke : 'rgba(60,141,188,1)',
						data                 : [ <?php echo $bar_sales; ?> ]
					},
					{
						label                : 'Purchase',
						backgroundColor      : 'rgba(210, 214, 222, 1)',
						borderColor          : 'rgba(210, 214, 222, 1)',
						pointRadius          : false,
						pointColor           : 'rgba(210, 214, 222, 1)',
						pointStrokeColor     : '#c1c7d1',
						pointHighlightFill   : '#fff',
						pointHighlightStroke : 'rgba(220,220,220,1)',
						data                 : [ <?php echo $bar_purchase; ?> ]
					},
				]
			};
			var barChartOptions = {
				responsive          : true,
				maintainAspectRatio : false,
				datasetFill         : false
			};
			//Create bar chart
			new Chart(barChartCanvas, {
				type    : 'bar',
				data    : barChartData,
				options : barChartOptions
			});

			//-------------
			//- PIE CHART -
			//-------------
			// Get context with jQuery - using jQuery's .get() method.
			var pieChartCanvas = $( '#pieChart' ).get( 0 ).getContext( '2d' );
			var pieData        = {
				labels   : [ <?php echo $pie_labels; ?> ],
				datasets : [
					{
						data            : [ <?php echo $pie_sales; ?> ],
						backgroundColor : [ <?php echo $pie_color; ?> ],
					}
				]
			};
			var pieOptions     = {
				maintainAspectRatio : false,
				responsive          : true,
			}
			//Create pie chart
			new Chart(pieChartCanvas, {
				type    : 'pie',
				data    : pieData,
				options : pieOptions
			});
		<?php } ?>

		$( '#data-table' ).DataTable({
			"paging": true,
			"lengthChange": true,
			"searching": true,
			"ordering": true,
			"info": true,
			"autoWidth": false,
			"responsive": true,
		});

		/** Initialize Select2 Elements */
		$('.select2').select2({
			theme: "bootstrap4",
			// width: 'auto',
		});
		$(document).on('select2:open', () => {
			document.querySelector('.select2-search__field').focus();
		});

		$( '.datepicker' ).datetimepicker({
			format: 'DD/MM/YYYY'
		});
	});
</script>

<!-- <script type="text/javascript">
    $(function($) {
        // this script needs to be loaded on every page where an ajax POST might happen for CSRF check
        $.ajaxSetup({
            headers: {
                'X-CSRF-Token': '<?php //echo $this->security->get_csrf_hash(); ?>'
            },
            data: {
                '<?php //echo $this->security->get_csrf_token_name(); ?>' : '<?php //echo $this->security->get_csrf_hash(); ?>'
            }
        });
    });
</script> -->

<?php if ( $menu == 'pos' ) { ?>
	<script src="assets/js/pos.js"></script>
<?php } else { ?>
	<script src="assets/js/apps.js"></script>
<?php } ?>