<?php
//ini_set('display_error',1);
date_default_timezone_set('America/Lima');
session_start();
if($_SESSION["sistema"]!= "1"){ header("location: ../login/index.php"); exit();}

require_once ("../../config/Cado.php");
require_once ("../formatos/formato.php");
require_once ("../formatos/fechas.php");
require_once ("../grafica/cGrafica.php");
$oGrafica = new cGrafica();


//echo $_POST['anio'];

?>
<style type="text/css">
select{
	cursor:pointer;
}

</style>


<div id="productostock" class="col-lg-12 col-sm-12 col-xs-12" style="height:400px;" ></div>

<script type="text/javascript">



	$(function() {
		
		Highcharts.chart('productostock', {

    chart: {
        type: 'item'
    },

    title: {
        text: 'TOP PRODUCTOS CON MENOS STOCK'
    },

    subtitle: {
        text: 'Servicios y sistemas informaticos'
    },

    legend: {
        labelFormat: '{name} <span style="opacity: 0.8">{y}</span>'
    },

    series: [{
        name: 'Stock',
        keys: ['name', 'y', 'color', 'label'],
        data: [
		
		
		<?php
			
			$_SESSION['colores'][1]= "#BE3075";
			$_SESSION['colores'][2]= "#EB001F";
			$_SESSION['colores'][3]= "#64A12D";
			$_SESSION['colores'][4]= "#FFED00";
			$_SESSION['colores'][5]= "#5E35B1";
			$_SESSION['colores'][6]= "#008AC5";
			$_SESSION['colores'][7]= "#009EE0";
			$_SESSION['colores'][8]= "#0288D1";
			$_SESSION['colores'][9]= "#1DE9B6";
			$_SESSION['colores'][10]= "#00E5FF";
			$_SESSION['colores'][11]= "#84FFFF";
			$_SESSION['colores'][12]= "#01579B";
			$_SESSION['colores'][13]= "#FFEB3B";
			$_SESSION['colores'][14]= "#F57F17";
			$_SESSION['colores'][15]= "#303F9F";
			$_SESSION['colores'][16]= "#C51162";
			$_SESSION['colores'][17]= "#FF80AB";
			$_SESSION['colores'][18]= "#AA00FF";
			$_SESSION['colores'][19]= "#C62828";
			$_SESSION['colores'][20]= "#6200EA";
		
			$dts1 =	$oGrafica->mostrar_productostock($_POST['cat_id'],$_POST['mar_id'],$_POST['top']);
			$i = 1;
			while($dt = mysqli_fetch_array($dts1)){
				$codcol = $_SESSION['colores'][$i];
				$i++;
			?>
			['<?php echo $dt["tb_producto_nom"]; ?>', <?php echo $dt["tb_stock_num"]; ?>, '<?php echo $codcol; ?>', '<?php echo $dt["tb_producto_nom"]; ?>'],
			<?php
			
			}

		?>
			
        ],
        dataLabels: {
            enabled: true,
            format: '{point.label}'
        },

        // Circular options
        center: ['50%', '88%'],
        size: '170%',
        startAngle: -100,
        endAngle: 100
    }],

    responsive: {
        rules: [{
            condition: {
                maxWidth: 600
            },
            chartOptions: {
                series: [{
                    dataLabels: {
                        distance: -30
                    }
                }]
            }
        }]
    }
});

	}); 

</script>
