I am working on a PHP file that will export data from a table to an Excel file. One piece of code I need to use is in a file that I included in the current file. When I try to run the code, however, I get the following error: Fatal error: Call to undefined function buscarFaltantesPorProveedor() in /require/exportarFaltantesExcel.php on line 13.
I am guessing I get this error because I am calling a class variable, but I am not sure. Can you please help me? Thanks!
PHP excel code:
<?php
error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', 1);
include('../accesodatos/consultas.php');
require_once('../excel/Classes/PHPExcel.php');
require_once('../excel/Classes/PHPExcel/IOFactory.php');    
$proveedor = $_GET['proveedor'];
echo $proveedor;
$objPHPExcel = new PHPExcel();
 // $objPHPExcel = new PHPExcel();
$query = buscarFaltantesPorProveedor($proveedor);
 $row = 1;
 while($row_data = mysql_fetch_array($query)){
    $col = 0;
    foreach($row_data as $key=>$value) {
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
        $col++;
    }
    $row++;
}
 header('Content-Type: application/vnd.openxmlformats-   officedocument.spreadsheetml.sheet');
 header('Content-Disposition: attachment;filename="'.$proveedor.date("Y-m-d").'".xlsx"');
 header('Cache-Control: max-age=0');
 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
 $objWriter->save('php://output');
?>
Piece of code in consultas.php:
function buscarFaltantesPorProveedor($proveedor){
conectar();
if(strcmp($proveedor,"Todos") == 0){
    $instruccion = "SELECT * FROM articulos, estatus, ordenes, proveedor WHERE art_id_estatus = est_id AND art_id_orden = ord_id AND art_id_proveedor = pro_id_clave AND art_num_guia IS NULL";
}else{
    $instruccion = "SELECT * FROM articulos, estatus, ordenes, proveedor WHERE art_id_estatus = est_id AND art_id_orden = ord_id AND art_id_proveedor = pro_id_clave AND art_num_guia IS NULL and pro_id_clave = '$proveedor'";
}
$tabla = mysql_query($instruccion);
return $tabla;
}
Also, I tried using $this to call the method but I also got an error. Why is that? Can't I use $this on a method?
 
     
    