forked from Wavyzz/dolibarr
Standardize code
This commit is contained in:
@@ -432,7 +432,6 @@ class BOM extends CommonObject
|
||||
* Load object lines in memory from the database by type of product
|
||||
*
|
||||
* @param int<0,1> $typeproduct 0 type product, 1 type service
|
||||
*
|
||||
* @return int<-1,1> Return integer <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetchLinesbytypeproduct($typeproduct = 0)
|
||||
@@ -469,6 +468,11 @@ class BOM extends CommonObject
|
||||
'@phan-var-force BOMLine $newline';
|
||||
$newline->setVarsFromFetchObj($obj);
|
||||
|
||||
// Load also extrafields for the line
|
||||
//if (empty($noextrafields)) {
|
||||
$newline->fetch_optionals();
|
||||
//}
|
||||
|
||||
$this->lines[] = $newline;
|
||||
}
|
||||
$i++;
|
||||
|
||||
@@ -32,6 +32,11 @@ function bomAdminPrepareHead()
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
global $db;
|
||||
$extrafields = new ExtraFields($db);
|
||||
$extrafields->fetch_name_optionals_label('bom_bom');
|
||||
$extrafields->fetch_name_optionals_label('bom_bomline');
|
||||
|
||||
$langs->load("mrp");
|
||||
|
||||
$h = 0;
|
||||
@@ -44,11 +49,19 @@ function bomAdminPrepareHead()
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/bom_extrafields.php";
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$nbExtrafields = is_countable($extrafields->attributes['bom_bom']['label']) ? count($extrafields->attributes['bom_bom']['label']) : 0;
|
||||
if ($nbExtrafields > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
|
||||
}
|
||||
$head[$h][2] = 'bom_extrafields';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/bomline_extrafields.php";
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
||||
$nbExtrafields = is_countable($extrafields->attributes['bom_bomline']['label']) ? count($extrafields->attributes['bom_bomline']['label']) : 0;
|
||||
if ($nbExtrafields > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
|
||||
}
|
||||
$head[$h][2] = 'bomline_extrafields';
|
||||
$h++;
|
||||
|
||||
|
||||
@@ -5354,8 +5354,8 @@ abstract class CommonObject
|
||||
|
||||
print "<!-- begin printObjectLines() -->\n";
|
||||
foreach ($this->lines as $line) {
|
||||
//Line extrafield
|
||||
$line->fetch_optionals();
|
||||
// Line extrafield. TODO Remove this. extrafields should be already loaded.
|
||||
//$line->fetch_optionals();
|
||||
|
||||
if (is_object($hookmanager)) {
|
||||
if (empty($line->fk_parent_line)) {
|
||||
@@ -5366,7 +5366,7 @@ abstract class CommonObject
|
||||
$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
}
|
||||
if (empty($reshook) && $buyer !== null) {
|
||||
if (empty($reshook)) {
|
||||
$this->printObjectLine($action, $line, '', $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir);
|
||||
}
|
||||
|
||||
@@ -5387,7 +5387,7 @@ abstract class CommonObject
|
||||
* @param int $i I
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param Societe $seller Object of seller third party
|
||||
* @param Societe $buyer Object of buyer third party
|
||||
* @param ?Societe $buyer Object of buyer third party
|
||||
* @param int $selected ID line selected
|
||||
* @param ?ExtraFields $extrafields Object of extrafields
|
||||
* @param string $defaulttpldir Directory where to find the template (deprecated)
|
||||
@@ -6348,7 +6348,6 @@ abstract class CommonObject
|
||||
$sql .= " WHERE type_object = '".$this->db->escape($element)."'";
|
||||
$sql .= " AND fk_object = ".((int) $this->id);
|
||||
|
||||
//dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$numrows = $this->db->num_rows($resql);
|
||||
@@ -10716,11 +10715,10 @@ abstract class CommonObject
|
||||
'@phan-var-force CommonObjectLine $newline';
|
||||
$newline->setVarsFromFetchObj($obj);
|
||||
|
||||
// Note: extrafields load of line not yet supported
|
||||
/*
|
||||
if (empty($noextrafields)) {
|
||||
// Load extrafields of line
|
||||
}*/
|
||||
// Load also extrafields for the line
|
||||
if (empty($noextrafields)) {
|
||||
$newline->fetch_optionals();
|
||||
}
|
||||
|
||||
$this->lines[] = $newline;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -49,10 +49,19 @@ function mymoduleAdminPrepareHead()
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$nbExtrafields = is_countable($extrafields->attributes['myobject']['label']) ? count($extrafields->attributes['myobject']['label']) : 0;
|
||||
if ($nbExtrafields > 0) {
|
||||
$head[$h][1] .= ' <span class="badge">' . $nbExtrafields . '</span>';
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
|
||||
}
|
||||
$head[$h][2] = 'myobject_extrafields';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = dol_buildpath("/mymodule/admin/myobjectline_extrafields.php", 1);
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
||||
$nbExtrafields = is_countable($extrafields->attributes['myobjectline']['label']) ? count($extrafields->attributes['myobject']['label']) : 0;
|
||||
if ($nbExtrafields > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
|
||||
}
|
||||
$head[$h][2] = 'myobject_extrafieldsline';
|
||||
$h++;
|
||||
*/
|
||||
|
||||
$head[$h][0] = dol_buildpath("/mymodule/admin/about.php", 1);
|
||||
|
||||
Reference in New Issue
Block a user