FIX not use $this in static function

This commit is contained in:
Regis Houssin 2022-01-27 14:17:14 +01:00
parent 64119917a4
commit 8196134345
2 changed files with 12 additions and 10 deletions

View File

@ -7388,6 +7388,8 @@ class Form
*/ */
protected static function forgeCriteriaCallback($matches) protected static function forgeCriteriaCallback($matches)
{ {
global $db;
//dol_syslog("Convert matches ".$matches[1]); //dol_syslog("Convert matches ".$matches[1]);
if (empty($matches[1])) { if (empty($matches[1])) {
return ''; return '';
@ -7400,11 +7402,11 @@ class Form
$tmpescaped = $tmp[2]; $tmpescaped = $tmp[2];
$regbis = array(); $regbis = array();
if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) {
$tmpescaped = "'".$this->db->escape($regbis[1])."'"; $tmpescaped = "'".$db->escape($regbis[1])."'";
} else { } else {
$tmpescaped = $$this->db->escape($tmpescaped); $tmpescaped = $db->escape($tmpescaped);
} }
return $$this->db->escape($tmp[0]).' '.strtoupper($$this->db->escape($tmp[1]))." ".$tmpescaped; return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
} }
/** /**

View File

@ -436,7 +436,7 @@ class Productbatch extends CommonObject
*/ */
public static function findAll($db, $fk_product_stock, $with_qty = 0, $fk_product = 0) public static function findAll($db, $fk_product_stock, $with_qty = 0, $fk_product = 0)
{ {
global $langs, $conf; global $conf;
$ret = array(); $ret = array();
@ -453,9 +453,9 @@ class Productbatch extends CommonObject
$sql .= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby"; $sql .= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby";
// TODO May add extrafields to ? // TODO May add extrafields to ?
} }
$sql .= " FROM ".$this->db->prefix()."product_batch as t"; $sql .= " FROM ".$db->prefix()."product_batch as t";
if ($fk_product > 0) { if ($fk_product > 0) {
$sql .= " LEFT JOIN ".$this->db->prefix()."product_lot as pl ON pl.fk_product = ".((int) $fk_product)." AND pl.batch = t.batch"; $sql .= " LEFT JOIN ".$db->prefix()."product_lot as pl ON pl.fk_product = ".((int) $fk_product)." AND pl.batch = t.batch";
// TODO May add extrafields to ? // TODO May add extrafields to ?
} }
$sql .= " WHERE fk_product_stock=".((int) $fk_product_stock); $sql .= " WHERE fk_product_stock=".((int) $fk_product_stock);
@ -526,10 +526,10 @@ class Productbatch extends CommonObject
$sql .= ", pl.sellby"; $sql .= ", pl.sellby";
$sql .= ", pl.eatby"; $sql .= ", pl.eatby";
$sql .= ", pb.qty"; $sql .= ", pb.qty";
$sql .= " FROM ".$this->db->prefix()."product_lot as pl"; $sql .= " FROM ".$db->prefix()."product_lot as pl";
$sql .= " LEFT JOIN ".$this->db->prefix()."product as p ON p.rowid = pl.fk_product"; $sql .= " LEFT JOIN ".$db->prefix()."product as p ON p.rowid = pl.fk_product";
$sql .= " LEFT JOIN ".$this->db->prefix()."product_batch AS pb ON pl.batch = pb.batch"; $sql .= " LEFT JOIN ".$db->prefix()."product_batch AS pb ON pl.batch = pb.batch";
$sql .= " LEFT JOIN ".$this->db->prefix()."product_stock AS ps ON ps.rowid = pb.fk_product_stock"; $sql .= " LEFT JOIN ".$db->prefix()."product_stock AS ps ON ps.rowid = pb.fk_product_stock";
$sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " WHERE p.entity IN (".getEntity('product').")";
$sql .= " AND pl.fk_product = ".((int) $fk_product); $sql .= " AND pl.fk_product = ".((int) $fk_product);
if ($fk_warehouse > 0) { if ($fk_warehouse > 0) {