<?php
session_start();
require('../fpdf/fpdf.php');
require('plantilla_general.php');
require '../../../conexion.php';
require_once('../../../include/sesiones.php');
$desde=$_GET['desde'];
$hasta=$_GET['hasta'];

$pdf=new PDF_MC_Table();
$pdf->AddPage();
$pdf->SetFont('Arial','',14);
$pdf->AliasNbPages();
//Table with 20 rows and 4 columns

$pdf->Cell(0,10,'DEVOLUCIONES DESDE '.$desde. ' HASTA ' .$hasta,0,1);
   
$pdf->SetFillColor(235,225,215);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(30,5,'FECHA',1,0,'C',1);
$pdf->Cell(20,5,'CANTIDAD',1,0,'C',1);
$pdf->Cell(25,5,'REFERENCIA',1,0,'C',1);
$pdf->Cell(95,5,'NOMBRE',1,0,'C',1);
$pdf->Cell(20,5,'PRECIO',1,0,'C',1);
$pdf->Ln();    


$total=0;
$registros=mysqli_query($con,"SELECT * FROM devolucion where DATE(dev_fecha) BETWEEN '$desde' AND '$hasta' and empresa='$empresa' order by dev_id desc") or die(mysqli_error($con));
while ($reg=mysqli_fetch_array($registros))
{
    $pdf->SetWidths(array(30,20,25,95,20));
    srand(time()*1000000);
    $pdf->Row(array($reg['dev_fecha'],$reg['dev_cantidad'],$reg['dev_referencia'],utf8_decode($reg['dev_nombre']),$reg['dev_precio']));
    $total+=$reg['dev_precio'];
}
$pdf->SetFillColor(135,245,115);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(150,5,'',1,0,'C',1);
$pdf->Cell(20,5,'TOTAL',1,0,'C',1);
$pdf->Cell(20,5,number_format($total,0),1,0,'R',1);
$pdf->Ln();       
          
$pdf->Output();

?>
