Fix undefined variable $pages in producto Search() function
Initialized $pages array in else block to prevent undefined variable warning when no search criteria are provided and SQL returns results.
This commit is contained in:
@@ -661,6 +661,63 @@ class Producto extends Main
|
||||
|
||||
}//Search3
|
||||
|
||||
function Search(){
|
||||
|
||||
$sqlAdd = '';
|
||||
|
||||
if($this->noProveedor)
|
||||
$sqlAdd .= ' AND prov.noProv = "'.$this->noProveedor.'"';
|
||||
|
||||
if($this->proveedorId)
|
||||
$sqlAdd .= ' AND p.proveedorId = "'.$this->proveedorId.'"';
|
||||
|
||||
if($this->prodCatId)
|
||||
$sqlAdd .= ' AND p.prodCatId = "'.$this->prodCatId.'"';
|
||||
|
||||
if($this->descripcion)
|
||||
$sqlAdd .= ' AND p.modelo LIKE "%'.$this->descripcion.'%"';
|
||||
|
||||
if($this->codigoBarra)
|
||||
$sqlAdd .= ' AND p.codigoBarra LIKE "%'.$this->codigoBarra.'%"';
|
||||
|
||||
if($sqlAdd != ''){
|
||||
|
||||
$sql = 'SELECT p.*
|
||||
|
||||
FROM
|
||||
producto AS p,
|
||||
proveedor AS prov
|
||||
WHERE
|
||||
p.proveedorId = prov.proveedorId
|
||||
AND
|
||||
p.baja = "0"
|
||||
'.$sqlAdd.'
|
||||
ORDER BY
|
||||
descripcion';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
}else{
|
||||
$result = array();
|
||||
$pages = array(
|
||||
'numbers' => array(),
|
||||
'first' => false,
|
||||
'prev' => false,
|
||||
'next' => false,
|
||||
'last' => false,
|
||||
'current' => 1,
|
||||
'items_per_page' => defined('ITEMS_PER_PAGE') ? ITEMS_PER_PAGE : 20,
|
||||
'start' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
|
||||
}//Search
|
||||
|
||||
function Search2(){
|
||||
|
||||
$sqlAdd = '';
|
||||
|
||||
Reference in New Issue
Block a user