<?
$r = "../";
require_once($r."inc/funciones.php");
$mysqli = connectDB($r);
$con = $_POST['con'];
$de = $_POST['de'];
$a = $_POST['a'];
if($con=='consu'){
    $sql1=$mysqli->query("SELECT  SUM(`monto`) AS 'total', `idmedio` FROM `z_pagos` WHERE `fecha`  BETWEEN '$de 00:00:00.000000' AND '$a 23:59:59.999999' GROUP BY idmedio");
    $table = '<table class="table">';
    while($row1=$sql1->fetch_assoc()){
        $medio = sinfo('z_pagos_medios',$row1['idmedio'])['medio'];
        $monto = moneda($row1['total']);
        $table .= "<tr><td>$medio</td><td>$monto</td></tr>";
    }
    $table .= '</table>';
    echo $table;
    exit();
}
if($con=='hoy'){
    $sql1=$mysqli->query("SELECT SUM(`monto`) AS 'total', `idmedio` FROM `z_pagos` WHERE `fecha`  LIKE '%$a%' GROUP BY idmedio");
    $table = '<table class="table">';
    while($row1=$sql1->fetch_assoc()){
        $medio = sinfo('z_pagos_medios',$row1['idmedio'])['medio'];
        $monto = moneda($row1['total']);
        $table .= "<tr><td>$medio</td><td>$monto</td></tr>";
    }
    $table .= '</table>';
    echo $table;
    exit();
}
if($con=='mes'){
    $sql1=$mysqli->query("SELECT  SUM(`monto`) AS 'total', `idmedio` FROM `z_pagos` WHERE `fecha`  LIKE '%$a%' GROUP BY idmedio");
    $table = '<table class="table">';
    while($row1=$sql1->fetch_assoc()){
        $medio = sinfo('z_pagos_medios',$row1['idmedio'])['medio'];
        $monto = moneda($row1['total']);
        $table .= "<tr><td>$medio</td><td>$monto</td></tr>";
    }
    $table .= '</table>';
    echo $table;
    exit();
}
if($con=='umes'){
    $sql1=$mysqli->query("SELECT  SUM(`monto`) AS 'total', `idmedio` FROM `z_pagos` WHERE `fecha`  BETWEEN '$de' AND '$a' GROUP BY idmedio");
    $table = '<table class="table">';
    while($row1=$sql1->fetch_assoc()){
        $medio = sinfo('z_pagos_medios',$row1['idmedio'])['medio'];
        $monto = moneda($row1['total']);
        $table .= "<tr><td>$medio</td><td>$monto</td></tr>";
    }
    $table .= '</table>';
    echo $table;
    exit();
}

?>