Fix php8 compatibility

This commit is contained in:
Laurent Destailleur 2022-12-30 14:56:55 +01:00
parent 5d84084396
commit 95986647b4
6 changed files with 1 additions and 290 deletions

View File

@ -116,30 +116,5 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1);
}
}
if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
* @param int $limit Limit number of responses
* @param int $offset Offset for first response
* @param string $sortfield Sort field
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @return void
*/
public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
// phpcs:enable
global $conf, $langs;
//$this->getFieldList();
$this->list_datas = array();
}
}

View File

@ -115,30 +115,5 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
}
if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
* @param int $limit Limit number of responses
* @param int $offset Offset for first response
* @param string $sortfield Sort field
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @return void
*/
public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
// phpcs:enable
global $conf, $langs;
//$this->getFieldList();
$this->list_datas = array();
}
}

View File

@ -164,6 +164,7 @@ class Canvas
*/
public function displayCanvasExists($action)
{
// template_dir should be '/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/', for example '/mymodule/canvas/product/tpl'
if (empty($this->template_dir)) {
return 0;
}

View File

@ -39,7 +39,6 @@ class ActionsCardProduct
// List of fiels for action=list
public $field_list = array();
public $list_datas = array();
/**
@ -88,8 +87,6 @@ class ActionsCardProduct
}
$this->object = $tmpobject;
//parent::assign_values($action);
foreach ($this->object as $key => $value) {
$this->tpl[$key] = $value;
}
@ -227,10 +224,6 @@ class ActionsCardProduct
$this->tpl['fiche_end'] = dol_get_fiche_end();
}
if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
}
@ -281,136 +274,4 @@ class ActionsCardProduct
dol_print_error($this->db, $sql);
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
* @param int $limit Limit number of responses
* @param int $offset Offset for first response
* @param string $sortfield Sort field
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @return void
*/
public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
// phpcs:enable
global $conf, $langs;
$this->getFieldListCanvas();
$this->list_datas = array();
// Clean parameters
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
foreach ($this->field_list as $field) {
if ($field['enabled']) {
$fieldname = "s".$field['alias'];
$$fieldname = GETPOST($fieldname);
}
}
$sql = 'SELECT DISTINCT ';
// Fields requiered
$sql .= 'p.rowid, p.price_base_type, p.fk_product_type, p.seuil_stock_alerte, p.entity';
// Fields not requiered
foreach ($this->field_list as $field) {
if ($field['enabled']) {
$sql .= ", ".$field['name']." as ".$field['alias'];
}
}
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
$sql .= " WHERE p.entity IN (".getEntity('product').")";
if ($sall) {
$clause = '';
$sql .= " AND (";
foreach ($this->field_list as $field) {
if ($field['enabled']) {
$sql .= $clause." ".$field['name']." LIKE '%".$this->db->escape($sall)."%'";
if ($clause == '') {
$clause = ' OR';
}
}
}
$sql .= ")";
}
// Search fields
foreach ($this->field_list as $field) {
if ($field['enabled']) {
$fieldname = "s".$field['alias'];
if (${$fieldname}) {
$sql .= " AND ".$field['name']." LIKE '%".$this->db->escape(${$fieldname})."%'";
}
}
}
if (GETPOSTISSET("tosell")) {
$sql .= " AND p.tosell = ".((int) GETPOST("tosell", "int"));
}
if (GETPOSTISSET("canvas")) {
$sql .= " AND p.canvas = '".$this->db->escape(GETPOST("canvas"))."'";
}
$sql .= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->plimit($limit + 1, $offset);
//print $sql;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < min($num, $limit)) {
$datas = array();
$obj = $this->db->fetch_object($resql);
$datas["id"] = $obj->rowid;
foreach ($this->field_list as $field) {
if ($field['enabled']) {
$alias = $field['alias'];
if ($alias == 'ref') {
$this->id = $obj->rowid;
$this->ref = $obj->$alias;
$this->type = $obj->fk_product_type;
$this->entity = $obj->entity;
$datas[$alias] = $this->getNomUrl(1, '', 24);
} elseif ($alias == 'stock') {
$this->load_stock();
if ($this->stock_reel < $obj->seuil_stock_alerte) {
$datas[$alias] = $this->stock_reel.' '.img_warning($langs->trans("StockTooLow"));
} else {
$datas[$alias] = $this->stock_reel;
}
} elseif ($alias == 'label') {
$datas[$alias] = dol_trunc($obj->$alias, 40);
} elseif (preg_match('/price/i', $alias)) {
$datas[$alias] = price($obj->$alias);
} elseif ($alias == 'datem') {
$datas[$alias] = dol_print_date($this->db->jdate($obj->$alias), 'day');
} elseif ($alias == 'status') {
$datas[$alias] = $this->LibStatut($obj->$alias, 5);
} else {
$datas[$alias] = $obj->$alias;
}
}
}
array_push($this->list_datas, $datas);
$i++;
}
$this->db->free($resql);
} else {
dol_print_error($this->db);
}
}
}

View File

@ -37,7 +37,6 @@ class ActionsCardService
// List of fiels for action=list
public $field_list = array();
public $list_datas = array();
public $id;
public $ref;
@ -92,8 +91,6 @@ class ActionsCardService
}
$this->object = $tmpobject;
//parent::assign_values($action);
foreach ($this->object as $key => $value) {
$this->tpl[$key] = $value;
}
@ -213,10 +210,6 @@ class ActionsCardService
$this->tpl['fiche_end'] = dol_get_fiche_end();
}
if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
}
@ -267,97 +260,4 @@ class ActionsCardService
dol_print_error($this->db, $sql);
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
* @param int $limit Limit number of responses
* @param int $offset Offset for first response
* @param string $sortfield Sort field
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @return void
*/
public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
// phpcs:enable
global $conf;
global $search_categ, $sall, $sref, $search_barcode, $snom, $catid;
$this->getFieldListCanvas();
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,';
$sql .= ' p.fk_product_type, p.tms as datem,';
$sql .= ' p.duration, p.tosell as statut, p.seuil_stock_alerte';
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
// We'll need this table joined to the select in order to filter by categ
if ($search_categ) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp";
}
$fourn_id = 0;
if (GETPOST("fourn_id", 'int') > 0) {
$fourn_id = GETPOST("fourn_id", 'int');
$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
}
$sql .= " WHERE p.entity IN (".getEntity('product').")";
if ($search_categ) {
$sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
}
if ($sall) {
$sql .= " AND (p.ref LIKE '%".$this->db->escape($sall)."%' OR p.label LIKE '%".$this->db->escape($sall)."%' OR p.description LIKE '%".$this->db->escape($sall)."%' OR p.note LIKE '%".$this->db->escape($sall)."%')";
}
if ($sref) {
$sql .= " AND p.ref LIKE '%".$this->db->escape($sref)."%'";
}
if ($search_barcode) {
$sql .= " AND p.barcode LIKE '%".$this->db->escape($search_barcode)."%'";
}
if ($snom) {
$sql .= " AND p.label LIKE '%".$this->db->escape($snom)."%'";
}
if (GETPOSTISSET("tosell")) {
$sql .= " AND p.tosell = ".((int) GETPOST("tosell", 'int'));
}
if (GETPOSTISSET("canvas")) {
$sql .= " AND p.canvas = '".$this->db->escape(GETPOST("canvas"))."'";
}
if ($catid) {
$sql .= " AND cp.fk_categorie = ".((int) $catid);
}
if ($fourn_id > 0) {
$sql .= " AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".((int) $fourn_id);
}
// Insert categ filter
if ($search_categ) {
$sql .= " AND cp.fk_categorie = ".((int) $search_categ);
}
$sql .= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->plimit($limit + 1, $offset);
$this->list_datas = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < min($num, $limit)) {
$datas = array();
$obj = $this->db->fetch_object($resql);
$datas["id"] = $obj->rowid;
$datas["ref"] = $obj->ref;
$datas["label"] = $obj->label;
$datas["barcode"] = $obj->barcode;
$datas["statut"] = $obj->statut;
array_push($this->list_datas, $datas);
$i++;
}
$this->db->free($resql);
} else {
print $sql;
}
}
}

View File

@ -1250,7 +1250,6 @@ if (isModEnabled('barcode') && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
}
}
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// When used with CANVAS