<?
$r="../";
require_once($r."inc/funciones.php");
validNotSession($r);
$mysqli = connectDB($r);
$spe=$_SESSION['perfil'];
$sql="";
$ver=$_GET['ver'];
if($ver=="1"){$tabla="z_productos";$parametro="id";$parametro1="producto";$parametro2="idproducto";}
elseif($ver=="2"){$tabla="z_ruteros";$parametro="id";$parametro1="nombre";$parametro2="idrutero";}

$ruta=$_GET['ruta'];
if($ruta!=""){$sql.='WHERE z_clientes.ruta='.$ruta;}
$tipo=$_GET['tipo'];
if($tipo!=""){if($sql!=""){$sql.=' AND ';}else{$sql.= ' WHERE ';} $sql.='z_clientes.tipocliente='.$tipo;}
$estado=$_GET['estado'];
if($estado!=""){if($sql!=""){$sql.=' AND ';}else{$sql.= ' WHERE ';} $sql.='z_pedidos.estado='.$estado;}
$pago=$_GET['pago'];
if($pago!=""){if($sql!=""){$sql.=' AND ';}else{$sql.= ' WHERE ';} $sql.='z_pedidos.pago='.$pago;}
$call=$_GET['call'];
if($call!=""){if($sql!=""){$sql.=' AND ';}else{$sql.= ' WHERE ';} $sql.='z_pedidos.iduser='.$call;}
$cliente=$_GET['cliente'];
if($cliente!=""){if($sql!=""){$sql.=' AND ';}else{$sql.=' WHERE ';}  $sql.='z_pedidos.idcliente='.$cliente;}
$inicio=$_GET['inicial'];if($inicio==""){$inicio="2019-01-01";}
$final=$_GET['final'];if($final==""){$final= date("Y-m-d");}
$arrayproductos= array();
$arrayidproductos= array();
$ene19 = array();$feb19 = array();$mar19 = array();$abr19 = array();$may19 = array();$jun19 = array();$jul19 = array();$ago19 = array();$sep19 = array();$oct19 = array();$nov19 = array();$dic19 = array();
$ene20 = array();$feb20 = array();$mar20 = array();$abr20 = array();$may20 = array();$jun20 = array();$jul20 = array();$ago20 = array();$sep20 = array();$oct20 = array();$nov20 = array();$dic20 = array();
$ene21 = array();$feb21 = array();$mar21 = array();$abr21 = array();$may21 = array();$jun21 = array();$jul21 = array();$ago21 = array();$sep21 = array();$oct21 = array();$nov21 = array();$dic21 = array();
$ene22 = array();$feb22 = array();$mar22 = array();$abr22 = array();$may22 = array();$jun22 = array();$jul22 = array();$ago22 = array();$sep22 = array();$oct22 = array();$nov22 = array();$dic22 = array();
$cero=0;

foreach($mysqli->query('SELECT idproducto,COUNT(*) FROM z_pedido GROUP BY idproducto') as $row) {
    if (in_array($row[idproducto], $_GET[productos], true)) {
    $productos = $mysqli->query("SELECT * FROM z_productos WHERE id=$row[idproducto]");
    $número_filas = mysqli_num_rows($productos);
    while($producto = $productos->fetch_assoc()){
        $idproducto=$producto[$parametro];
        $nomproducto=$producto[$parametro1];
        array_push($arrayproductos[$idproducto]=$nomproducto);
        //2019
        array_push($ene19[$idproducto]=$cero);array_push($feb19[$idproducto]=$cero);array_push($mar19[$idproducto]=$cero);array_push($abr19[$idproducto]=$cero);array_push($may19[$idproducto]=$cero);array_push($jun19[$idproducto]=$cero);
        array_push($jul19[$idproducto]=$cero);array_push($ago19[$idproducto]=$cero);array_push($sep19[$idproducto]=$cero);array_push($oct19[$idproducto]=$cero);array_push($nov19[$idproducto]=$cero);array_push($dic19[$idproducto]=$cero);
        //2020
        array_push($ene20[$idproducto]=$cero);array_push($feb20[$idproducto]=$cero);array_push($mar20[$idproducto]=$cero);array_push($abr20[$idproducto]=$cero);array_push($may20[$idproducto]=$cero);array_push($jun20[$idproducto]=$cero);
        array_push($jul20[$idproducto]=$cero);array_push($ago20[$idproducto]=$cero);array_push($sep20[$idproducto]=$cero);array_push($oct20[$idproducto]=$cero);array_push($nov20[$idproducto]=$cero);array_push($dic20[$idproducto]=$cero);
        //2021
        array_push($ene21[$idproducto]=$cero);array_push($feb21[$idproducto]=$cero);array_push($mar21[$idproducto]=$cero);array_push($abr21[$idproducto]=$cero);array_push($may21[$idproducto]=$cero);array_push($jun21[$idproducto]=$cero);
        array_push($jul21[$idproducto]=$cero);array_push($ago21[$idproducto]=$cero);array_push($sep21[$idproducto]=$cero);array_push($oct21[$idproducto]=$cero);array_push($nov21[$idproducto]=$cero);array_push($dic21[$idproducto]=$cero);
        //2022
        array_push($ene22[$idproducto]=$cero);array_push($feb22[$idproducto]=$cero);array_push($mar22[$idproducto]=$cero);array_push($abr22[$idproducto]=$cero);array_push($may22[$idproducto]=$cero);array_push($jun22[$idproducto]=$cero);
        array_push($jul22[$idproducto]=$cero);array_push($ago22[$idproducto]=$cero);array_push($sep22[$idproducto]=$cero);array_push($oct22[$idproducto]=$cero);array_push($nov22[$idproducto]=$cero);array_push($dic22[$idproducto]=$cero);
    }
  }
}
                                                 
if($tipo=="" && $ruta==""){$row3=$mysqli->query("SELECT * FROM z_pedidos INNER JOIN z_pedido ON z_pedidos.codigopedido = z_pedido.codigopedido $sql AND z_pedidos.fecha BETWEEN '$inicio 00:00:00' AND '$final 23:59:59' ");}
                      else{$row3=$mysqli->query("SELECT * FROM z_pedidos INNER JOIN z_pedido ON z_pedidos.codigopedido = z_pedido.codigopedido INNER JOIN z_clientes ON z_pedidos.idcliente = z_clientes.id $sql AND z_pedidos.fecha BETWEEN '$inicio 00:00:00' AND '$final 23:59:59'");}
while($row4 = $row3->fetch_assoc()) {
    if (in_array($row4[idproducto], $_GET[productos], true)) {
    $fecha = $row4[fecha];
    $fechaComoEntero = strtotime($fecha);
    /* Asumimos que $fechaComoEntero es como su nombre lo dice una variable entera, que calculamos con los ejemplos mostrados arriba */
    $Y = date("Y", $fechaComoEntero);
    $m = date("m", $fechaComoEntero);
    if($Y=="2019"){
        if($m=="01"){$id=$row4[$parametro2];$suma1=$ene19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ene19[$id]=$suma1;$enes19=1;}
        if($m=="02"){$id=$row4[$parametro2];$suma1=$feb19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$feb19[$id]=$suma1;$febs19=1;}
        if($m=="03"){$id=$row4[$parametro2];$suma1=$mar19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$mar19[$id]=$suma1;$mars19=1;}
        if($m=="04"){$id=$row4[$parametro2];$suma1=$abr19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$abr19[$id]=$suma1;$abrs19=1;}
        if($m=="05"){$id=$row4[$parametro2];$suma1=$may19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$may19[$id]=$suma1;$mays19=1;}
        if($m=="06"){$id=$row4[$parametro2];$suma1=$jun19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jun19[$id]=$suma1;$juns19=1;}
        if($m=="07"){$id=$row4[$parametro2];$suma1=$jul19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jul19[$id]=$suma1;$juls19=1;}
        if($m=="08"){$id=$row4[$parametro2];$suma1=$ago19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ago19[$id]=$suma1;$agos19=1;}
        if($m=="09"){$id=$row4[$parametro2];$suma1=$sep19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$sep19[$id]=$suma1;$seps19=1;}
        if($m=="10"){$id=$row4[$parametro2];$suma1=$oct19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$oct19[$id]=$suma1;$octs19=1;}
        if($m=="11"){$id=$row4[$parametro2];$suma1=$nov19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$nov19[$id]=$suma1;$novs19=1;}
        if($m=="12"){$id=$row4[$parametro2];$suma1=$dic19[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$dic19[$id]=$suma1;$dics19=1;}
        
    }
    if($Y=="2020"){
        if($m=="01"){$id=$row4[$parametro2];$suma1=$ene20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ene20[$id]=$suma1;$enes20=1;}
        if($m=="02"){$id=$row4[$parametro2];$suma1=$feb20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$feb20[$id]=$suma1;$febs20=1;}
        if($m=="03"){$id=$row4[$parametro2];$suma1=$mar20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$mar20[$id]=$suma1;$mars20=1;}
        if($m=="04"){$id=$row4[$parametro2];$suma1=$abr20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$abr20[$id]=$suma1;$abrs20=1;}
        if($m=="05"){$id=$row4[$parametro2];$suma1=$may20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$may20[$id]=$suma1;$mays20=1;}
        if($m=="06"){$id=$row4[$parametro2];$suma1=$jun20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jun20[$id]=$suma1;$juns20=1;}
        if($m=="07"){$id=$row4[$parametro2];$suma1=$jul20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jul20[$id]=$suma1;$juls20=1;}
        if($m=="08"){$id=$row4[$parametro2];$suma1=$ago20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ago20[$id]=$suma1;$agos20=1;}
        if($m=="09"){$id=$row4[$parametro2];$suma1=$sep20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$sep20[$id]=$suma1;$seps20=1;}
        if($m=="10"){$id=$row4[$parametro2];$suma1=$oct20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$oct20[$id]=$suma1;$octs20=1;}
        if($m=="11"){$id=$row4[$parametro2];$suma1=$nov20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$nov20[$id]=$suma1;$novs20=1;}
        if($m=="12"){$id=$row4[$parametro2];$suma1=$dic20[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$dic20[$id]=$suma1;$dics20=1;}
        
    }
    if($Y=="2021"){
        if($m=="01"){$id=$row4[$parametro2];$suma1=$ene21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ene21[$id]=$suma1;$enes21=1;}
        if($m=="02"){$id=$row4[$parametro2];$suma1=$feb21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$feb21[$id]=$suma1;$febs21=1;}
        if($m=="03"){$id=$row4[$parametro2];$suma1=$mar21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$mar21[$id]=$suma1;$mars21=1;}
        if($m=="04"){$id=$row4[$parametro2];$suma1=$abr21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$abr21[$id]=$suma1;$abrs21=1;}
        if($m=="05"){$id=$row4[$parametro2];$suma1=$may21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$may21[$id]=$suma1;$mays21=1;}
        if($m=="06"){$id=$row4[$parametro2];$suma1=$jun21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jun21[$id]=$suma1;$juns21=1;}
        if($m=="07"){$id=$row4[$parametro2];$suma1=$jul21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jul21[$id]=$suma1;$juls21=1;}
        if($m=="08"){$id=$row4[$parametro2];$suma1=$ago21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ago21[$id]=$suma1;$agos21=1;}
        if($m=="09"){$id=$row4[$parametro2];$suma1=$sep21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$sep21[$id]=$suma1;$seps21=1;}
        if($m=="10"){$id=$row4[$parametro2];$suma1=$oct21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$oct21[$id]=$suma1;$octs21=1;}
        if($m=="11"){$id=$row4[$parametro2];$suma1=$nov21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$nov21[$id]=$suma1;$novs21=1;}
        if($m=="12"){$id=$row4[$parametro2];$suma1=$dic21[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$dic21[$id]=$suma1;$dics21=1;}
        
    }
    if($Y=="2022"){
        if($m=="01"){$id=$row4[$parametro2];$suma1=$ene22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ene22[$id]=$suma1;$enes22=1;}
        if($m=="02"){$id=$row4[$parametro2];$suma1=$feb22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$feb22[$id]=$suma1;$febs22=1;}
        if($m=="03"){$id=$row4[$parametro2];$suma1=$mar22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$mar22[$id]=$suma1;$mars22=1;}
        if($m=="04"){$id=$row4[$parametro2];$suma1=$abr22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$abr22[$id]=$suma1;$abrs22=1;}
        if($m=="05"){$id=$row4[$parametro2];$suma1=$may22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$may22[$id]=$suma1;$mays22=1;}
        if($m=="06"){$id=$row4[$parametro2];$suma1=$jun22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jun22[$id]=$suma1;$juns22=1;}
        if($m=="07"){$id=$row4[$parametro2];$suma1=$jul22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$jul22[$id]=$suma1;$juls22=1;}
        if($m=="08"){$id=$row4[$parametro2];$suma1=$ago22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$ago22[$id]=$suma1;$agos22=1;}
        if($m=="09"){$id=$row4[$parametro2];$suma1=$sep22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$sep22[$id]=$suma1;$seps22=1;}
        if($m=="10"){$id=$row4[$parametro2];$suma1=$oct22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$oct22[$id]=$suma1;$octs22=1;}
        if($m=="11"){$id=$row4[$parametro2];$suma1=$nov22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$nov22[$id]=$suma1;$novs22=1;}
        if($m=="12"){$id=$row4[$parametro2];$suma1=$dic22[$id];$suma1=$suma1+$row4[precio]*$row4[cantidad];$dic22[$id]=$suma1;$dics22=1;}
        
    }
    }
}
?>

<!DOCTYPE html>
<html lang="es">
  <?php include $r."inc/head.php"; ?>
  <link href="../vendor/chosen/chosen.css" rel="stylesheet">
  <link href="../vendor/buttons-master/component-buttons.min.css" rel="stylesheet" type="text/css">
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['bar']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['MES',<? setlocale(LC_MONETARY, 'en_US');foreach ($arrayproductos as $clave => $valor) {echo "'".$arrayproductos[$clave]."',";}?>],
          
          <?if($enes19==1){?>['Ene',<?foreach ($arrayproductos as $clave => $valor) {echo $ene19[$clave].',';}?>],<? } ?>
          <?if($febs19==1){?>['Feb',<?foreach ($arrayproductos as $clave => $valor) {echo $feb19[$clave].',';}?>],<? } ?>
          <?if($mars19==1){?>['Mar',<?foreach ($arrayproductos as $clave => $valor) {echo $mar19[$clave].',';}?>],<? } ?>
          <?if($abrs19==1){?>['Abr',<?foreach ($arrayproductos as $clave => $valor) {echo $abr19[$clave].',';}?>],<? } ?>
          <?if($mays19==1){?>['May',<?foreach ($arrayproductos as $clave => $valor) {echo $may19[$clave].',';}?>],<? } ?>
          <?if($juns19==1){?>['Jun',<?foreach ($arrayproductos as $clave => $valor) {echo $jun19[$clave].',';}?>],<? } ?>
          <?if($juls19==1){?>['Jul',<?foreach ($arrayproductos as $clave => $valor) {echo $jul19[$clave].',';}?>],<? } ?>
          <?if($agos19==1){?>['Ago',<?foreach ($arrayproductos as $clave => $valor) {echo $ago19[$clave].',';}?>],<? } ?>
          <?if($seps19==1){?>['Sep',<?foreach ($arrayproductos as $clave => $valor) {echo $sep19[$clave].',';}?>],<? } ?>
          <?if($octs19==1){?>['Oct',<?foreach ($arrayproductos as $clave => $valor) {echo $oct19[$clave].',';}?>],<? } ?>
          <?if($novs19==1){?>['Nov',<?foreach ($arrayproductos as $clave => $valor) {echo $nov19[$clave].',';}?>],<? } ?>
          <?if($dics19==1){?>['Dic',<?foreach ($arrayproductos as $clave => $valor) {echo $dic19[$clave].',';}?>],<? } ?>
          
          <?if($enes20==1){?>['Ene',<?foreach ($arrayproductos as $clave => $valor) {echo $ene20[$clave].',';}?>],<? } ?>
          <?if($febs20==1){?>['Feb',<?foreach ($arrayproductos as $clave => $valor) {echo $feb20[$clave].',';}?>],<? } ?>
          <?if($mars20==1){?>['Mar',<?foreach ($arrayproductos as $clave => $valor) {echo $mar20[$clave].',';}?>],<? } ?>
          <?if($abrs20==1){?>['Abr',<?foreach ($arrayproductos as $clave => $valor) {echo $abr20[$clave].',';}?>],<? } ?>
          <?if($mays20==1){?>['May',<?foreach ($arrayproductos as $clave => $valor) {echo $may20[$clave].',';}?>],<? } ?>
          <?if($juns20==1){?>['Jun',<?foreach ($arrayproductos as $clave => $valor) {echo $jun20[$clave].',';}?>],<? } ?>
          <?if($juls20==1){?>['Jul',<?foreach ($arrayproductos as $clave => $valor) {echo $jul20[$clave].',';}?>],<? } ?>
          <?if($agos20==1){?>['Ago',<?foreach ($arrayproductos as $clave => $valor) {echo $ago20[$clave].',';}?>],<? } ?>
          <?if($seps20==1){?>['Sep',<?foreach ($arrayproductos as $clave => $valor) {echo $sep20[$clave].',';}?>],<? } ?>
          <?if($octs20==1){?>['Oct',<?foreach ($arrayproductos as $clave => $valor) {echo $oct20[$clave].',';}?>],<? } ?>
          <?if($novs20==1){?>['Nov',<?foreach ($arrayproductos as $clave => $valor) {echo $nov20[$clave].',';}?>],<? } ?>
          <?if($dics20==1){?>['Dic',<?foreach ($arrayproductos as $clave => $valor) {echo $dic20[$clave].',';}?>],<? } ?>
          
          <?if($enes21==1){?>['Ene',<?foreach ($arrayproductos as $clave => $valor) {echo $ene21[$clave].',';}?>],<? } ?>
          <?if($febs21==1){?>['Feb',<?foreach ($arrayproductos as $clave => $valor) {echo $feb21[$clave].',';}?>],<? } ?>
          <?if($mars21==1){?>['Mar',<?foreach ($arrayproductos as $clave => $valor) {echo $mar21[$clave].',';}?>],<? } ?>
          <?if($abrs21==1){?>['Abr',<?foreach ($arrayproductos as $clave => $valor) {echo $abr21[$clave].',';}?>],<? } ?>
          <?if($mays21==1){?>['May',<?foreach ($arrayproductos as $clave => $valor) {echo $may21[$clave].',';}?>],<? } ?>
          <?if($juns21==1){?>['Jun',<?foreach ($arrayproductos as $clave => $valor) {echo $jun21[$clave].',';}?>],<? } ?>
          <?if($juls21==1){?>['Jul',<?foreach ($arrayproductos as $clave => $valor) {echo $jul21[$clave].',';}?>],<? } ?>
          <?if($agos21==1){?>['Ago',<?foreach ($arrayproductos as $clave => $valor) {echo $ago21[$clave].',';}?>],<? } ?>
          <?if($seps21==1){?>['Sep',<?foreach ($arrayproductos as $clave => $valor) {echo $sep21[$clave].',';}?>],<? } ?>
          <?if($octs21==1){?>['Oct',<?foreach ($arrayproductos as $clave => $valor) {echo $oct21[$clave].',';}?>],<? } ?>
          <?if($novs21==1){?>['Nov',<?foreach ($arrayproductos as $clave => $valor) {echo $nov21[$clave].',';}?>],<? } ?>
          <?if($dics21==1){?>['Dic',<?foreach ($arrayproductos as $clave => $valor) {echo $dic21[$clave].',';}?>],<? } ?>
          
          <?if($enes22==1){?>['Ene',<?foreach ($arrayproductos as $clave => $valor) {echo $ene22[$clave].',';}?>],<? } ?>
          <?if($febs22==1){?>['Feb',<?foreach ($arrayproductos as $clave => $valor) {echo $feb22[$clave].',';}?>],<? } ?>
          <?if($mars22==1){?>['Mar',<?foreach ($arrayproductos as $clave => $valor) {echo $mar22[$clave].',';}?>],<? } ?>
          <?if($abrs22==1){?>['Abr',<?foreach ($arrayproductos as $clave => $valor) {echo $abr22[$clave].',';}?>],<? } ?>
          <?if($mays22==1){?>['May',<?foreach ($arrayproductos as $clave => $valor) {echo $may22[$clave].',';}?>],<? } ?>
          <?if($juns22==1){?>['Jun',<?foreach ($arrayproductos as $clave => $valor) {echo $jun22[$clave].',';}?>],<? } ?>
          <?if($juls22==1){?>['Jul',<?foreach ($arrayproductos as $clave => $valor) {echo $jul22[$clave].',';}?>],<? } ?>
          <?if($agos22==1){?>['Ago',<?foreach ($arrayproductos as $clave => $valor) {echo $ago22[$clave].',';}?>],<? } ?>
          <?if($seps22==1){?>['Sep',<?foreach ($arrayproductos as $clave => $valor) {echo $sep22[$clave].',';}?>],<? } ?>
          <?if($octs22==1){?>['Oct',<?foreach ($arrayproductos as $clave => $valor) {echo $oct22[$clave].',';}?>],<? } ?>
          <?if($novs22==1){?>['Nov',<?foreach ($arrayproductos as $clave => $valor) {echo $nov22[$clave].',';}?>],<? } ?>
          <?if($dics22==1){?>['Dic',<?foreach ($arrayproductos as $clave => $valor) {echo $dic22[$clave].',';}?>],<? } ?>
        ]);

        var options = {
          chart: {
            title: 'PRACTIPASTAJJ',
            subtitle: 'Productos',
          },
          bars: 'vertical' // Required for Material Bar Charts.
        };

        var chart = new google.charts.Bar(document.getElementById('barchart_material'));

        chart.draw(data, google.charts.Bar.convertOptions(options));
      }
    </script>
    <style>
        table{
            border-collapse: collapse; /* Los bordes de la tabla se pegarán (mejor aspecto) */
            text-align:center;
        }
        td, th{
            border: 1px solid black;
        }
        th{
            font-size: 10px;
        }
    </style>
</head>  <style>
      .container-fluid{padding-right:5px;padding-left:5px;}
  </style>
<script>
  function limpiarFormulario() {
    document.getElementById("miForm").reset();
  }
</script>
<body class="fixed-nav sticky-footer sidenav-toggled bg-dark" id="page-top">
  <div class="content-wrapper">
    <div class="container-fluid">
      <?php include $r."inc/nav.php"; ?>
       
      <div id="barchart_material" style="width: 99vw; height: 500px;"></div>
    <table>
        <tr><th>MES</th><?foreach ($arrayproductos as $clave => $valor) {echo '<th>'.$arrayproductos[$clave].'</th>';}?><th>TOTAL</th></tr>
          
          <?if($enes19==1){?><tr><td>Ene</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ene19[$clave].'</td>';}?><td><? $suma5=array_sum($ene19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($febs19==1){?><tr><td>Feb</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$feb19[$clave].'</td>';}?><td><? $suma5=array_sum($feb19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mars19==1){?><tr><td>Mar</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$mar19[$clave].'</td>';}?><td><? $suma5=array_sum($mar19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($abrs19==1){?><tr><td>Abr</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$abr19[$clave].'</td>';}?><td><? $suma5=array_sum($abr19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mays19==1){?><tr><td>May</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$may19[$clave].'</td>';}?><td><? $suma5=array_sum($may19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juns19==1){?><tr><td>Jun</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jun19[$clave].'</td>';}?><td><? $suma5=array_sum($jun19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juls19==1){?><tr><td>Jul</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jul19[$clave].'</td>';}?><td><? $suma5=array_sum($jul19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($agos19==1){?><tr><td>Ago</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ago19[$clave].'</td>';}?><td><? $suma5=array_sum($ago19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($seps19==1){?><tr><td>Sep</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$sep19[$clave].'</td>';}?><td><? $suma5=array_sum($sep19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($octs19==1){?><tr><td>Oct</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$oct19[$clave].'</td>';}?><td><? $suma5=array_sum($oct19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($novs19==1){?><tr><td>Nov</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$nov19[$clave].'</td>';}?><td><? $suma5=array_sum($nov19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($dics19==1){?><tr><td>Dic</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$dic19[$clave].'</td>';}?><td><? $suma5=array_sum($dic19);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          
          <?if($enes20==1){?><tr><td>Ene</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ene20[$clave].'</td>';}?><td><? $suma5=array_sum($ene20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($febs20==1){?><tr><td>Feb</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$feb20[$clave].'</td>';}?><td><? $suma5=array_sum($feb20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mars20==1){?><tr><td>Mar</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$mar20[$clave].'</td>';}?><td><? $suma5=array_sum($mar20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($abrs20==1){?><tr><td>Abr</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$abr20[$clave].'</td>';}?><td><? $suma5=array_sum($abr20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mays20==1){?><tr><td>May</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$may20[$clave].'</td>';}?><td><? $suma5=array_sum($may20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juns20==1){?><tr><td>Jun</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jun20[$clave].'</td>';}?><td><? $suma5=array_sum($jun20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juls20==1){?><tr><td>Jul</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jul20[$clave].'</td>';}?><td><? $suma5=array_sum($jul20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($agos20==1){?><tr><td>Ago</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ago20[$clave].'</td>';}?><td><? $suma5=array_sum($ago20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($seps20==1){?><tr><td>Sep</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$sep20[$clave].'</td>';}?><td><? $suma5=array_sum($sep20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($octs20==1){?><tr><td>Oct</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$oct20[$clave].'</td>';}?><td><? $suma5=array_sum($oct20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($novs20==1){?><tr><td>Nov</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$nov20[$clave].'</td>';}?><td><? $suma5=array_sum($nov20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($dics20==1){?><tr><td>Dic</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$dic20[$clave].'</td>';}?><td><? $suma5=array_sum($dic20);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          
          <?if($enes21==1){?><tr><td>Ene</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ene21[$clave].'</td>';}?><td><? $suma5=array_sum($ene21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($febs21==1){?><tr><td>Feb</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$feb21[$clave].'</td>';}?><td><? $suma5=array_sum($feb21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mars21==1){?><tr><td>Mar</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$mar21[$clave].'</td>';}?><td><? $suma5=array_sum($mar21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($abrs21==1){?><tr><td>Abr</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$abr21[$clave].'</td>';}?><td><? $suma5=array_sum($abr21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mays21==1){?><tr><td>May</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$may21[$clave].'</td>';}?><td><? $suma5=array_sum($may21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juns21==1){?><tr><td>Jun</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jun21[$clave].'</td>';}?><td><? $suma5=array_sum($jun21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juls21==1){?><tr><td>Jul</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jul21[$clave].'</td>';}?><td><? $suma5=array_sum($jul21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($agos21==1){?><tr><td>Ago</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ago21[$clave].'</td>';}?><td><? $suma5=array_sum($ago21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($seps21==1){?><tr><td>Sep</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$sep21[$clave].'</td>';}?><td><? $suma5=array_sum($sep21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($octs21==1){?><tr><td>Oct</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$oct21[$clave].'</td>';}?><td><? $suma5=array_sum($oct21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($novs21==1){?><tr><td>Nov</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$nov21[$clave].'</td>';}?><td><? $suma5=array_sum($nov21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($dics21==1){?><tr><td>Dic</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$dic21[$clave].'</td>';}?><td><? $suma5=array_sum($dic21);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          
          <?if($enes22==1){?><tr><td>Ene</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ene22[$clave].'</td>';}?><td><? $suma5=array_sum($ene22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($febs22==1){?><tr><td>Feb</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$feb22[$clave].'</td>';}?><td><? $suma5=array_sum($feb22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mars22==1){?><tr><td>Mar</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$mar22[$clave].'</td>';}?><td><? $suma5=array_sum($mar22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($abrs22==1){?><tr><td>Abr</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$abr22[$clave].'</td>';}?><td><? $suma5=array_sum($abr22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($mays22==1){?><tr><td>May</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$may22[$clave].'</td>';}?><td><? $suma5=array_sum($may22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juns22==1){?><tr><td>Jun</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jun22[$clave].'</td>';}?><td><? $suma5=array_sum($jun22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($juls22==1){?><tr><td>Jul</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$jul22[$clave].'</td>';}?><td><? $suma5=array_sum($jul22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($agos22==1){?><tr><td>Ago</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$ago22[$clave].'</td>';}?><td><? $suma5=array_sum($ago22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($seps22==1){?><tr><td>Sep</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$sep22[$clave].'</td>';}?><td><? $suma5=array_sum($sep22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($octs22==1){?><tr><td>Oct</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$oct22[$clave].'</td>';}?><td><? $suma5=array_sum($oct22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($novs22==1){?><tr><td>Nov</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$nov22[$clave].'</td>';}?><td><? $suma5=array_sum($nov22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
          <?if($dics22==1){?><tr><td>Dic</td><?foreach ($arrayproductos as $clave => $valor) {echo '<td>'.$dic22[$clave].'</td>';}?><td><? $suma5=array_sum($dic22);echo money_format('%(#10.0n', $suma5); ?></td></tr><? } ?>
   </table>
   <div class="p-3 text-center">
     <a href="javascript:history.go(-1)" class="btn btn-primary m-1">Volver</a>
     <a href="productos.php" class="btn btn-primary m-1">Nueva Búsqueda</a>
   </div>
        
    <?php include $r."inc/foot.php"; ?>
    </div>
  </div>
</body>
</html>