Fixing style errors.

This commit is contained in:
stickler-ci 2020-12-21 11:34:51 +00:00
parent 7b739920a2
commit da9defe0ce
6 changed files with 27 additions and 36 deletions

View File

@ -77,7 +77,7 @@ class FormResource
* @param string $morecss More css * @param string $morecss More css
* @return string HTML string with * @return string HTML string with
*/ */
public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple=false) public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false)
{ {
// phpcs:enable // phpcs:enable
global $conf, $user, $langs; global $conf, $user, $langs;

View File

@ -233,8 +233,8 @@ class Workstation extends CommonObject
// Usergroups // Usergroups
$groups = GETPOST('groups'); $groups = GETPOST('groups');
if(empty($groups)) $groups = $this->usergroups; // createFromClone if (empty($groups)) $groups = $this->usergroups; // createFromClone
if(!empty($groups)) { if (!empty($groups)) {
foreach ($groups as $id_group) { foreach ($groups as $id_group) {
$ws_usergroup = new WorkstationUserGroup($db); $ws_usergroup = new WorkstationUserGroup($db);
$ws_usergroup->fk_workstation = $id; $ws_usergroup->fk_workstation = $id;
@ -246,8 +246,8 @@ class Workstation extends CommonObject
// Resources // Resources
$resources = GETPOST('resources'); $resources = GETPOST('resources');
if(empty($resources)) $resources = $this->resources; // createFromClone if (empty($resources)) $resources = $this->resources; // createFromClone
if(!empty($resources)) { if (!empty($resources)) {
foreach ($resources as $id_resource) { foreach ($resources as $id_resource) {
$ws_resource = new WorkstationResource($db); $ws_resource = new WorkstationResource($db);
$ws_resource->fk_workstation = $id; $ws_resource->fk_workstation = $id;
@ -490,7 +490,7 @@ class Workstation extends CommonObject
$resources = GETPOST('resources'); $resources = GETPOST('resources');
WorkstationResource::deleteAllResourcesOfWorkstation($this->id); WorkstationResource::deleteAllResourcesOfWorkstation($this->id);
$this->resources=array(); $this->resources=array();
if(!empty($resources)) { if (!empty($resources)) {
foreach ($resources as $id_resource) { foreach ($resources as $id_resource) {
$ws_resource = new WorkstationResource($this->db); $ws_resource = new WorkstationResource($this->db);
$ws_resource->fk_workstation = $this->id; $ws_resource->fk_workstation = $this->id;
@ -677,7 +677,7 @@ class Workstation extends CommonObject
$this->status = $status; $this->status = $status;
if(empty($status)) $this->setDisabled($user, $notrigger); if (empty($status)) $this->setDisabled($user, $notrigger);
else $this->setEnabled($user, $notrigger); else $this->setEnabled($user, $notrigger);
} }

View File

@ -46,7 +46,8 @@ class WorkstationResource extends CommonObject
} }
} }
static public function getAllResourcesOfWorkstation($fk_workstation) { static public function getAllResourcesOfWorkstation($fk_workstation)
{
global $db; global $db;
@ -55,17 +56,17 @@ class WorkstationResource extends CommonObject
$resql = $db->query($sql); $resql = $db->query($sql);
$TRes = array(); $TRes = array();
if(!empty($resql)) { if (!empty($resql)) {
while($res = $db->fetch_object($resql)) { while ($res = $db->fetch_object($resql)) {
$TRes[] = $res->fk_resource; $TRes[] = $res->fk_resource;
} }
} }
return $TRes; return $TRes;
} }
static public function deleteAllResourcesOfWorkstation($fk_workstation) { static public function deleteAllResourcesOfWorkstation($fk_workstation)
{
global $db; global $db;
@ -73,10 +74,8 @@ class WorkstationResource extends CommonObject
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$obj->table_element.' WHERE fk_workstation = '.$fk_workstation; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$obj->table_element.' WHERE fk_workstation = '.$fk_workstation;
$resql = $db->query($sql); $resql = $db->query($sql);
if(empty($resql)) return 0; if (empty($resql)) return 0;
return 1; return 1;
} }
} }

View File

@ -46,7 +46,8 @@ class WorkstationUserGroup extends CommonObject
} }
} }
static public function getAllGroupsOfWorkstation($fk_workstation) { static public function getAllGroupsOfWorkstation($fk_workstation)
{
global $db; global $db;
@ -55,17 +56,17 @@ class WorkstationUserGroup extends CommonObject
$resql = $db->query($sql); $resql = $db->query($sql);
$TRes = array(); $TRes = array();
if(!empty($resql)) { if (!empty($resql)) {
while($res = $db->fetch_object($resql)) { while ($res = $db->fetch_object($resql)) {
$TRes[] = $res->fk_usergroup; $TRes[] = $res->fk_usergroup;
} }
} }
return $TRes; return $TRes;
} }
static public function deleteAllGroupsOfWorkstation($fk_workstation) { static public function deleteAllGroupsOfWorkstation($fk_workstation)
{
global $db; global $db;
@ -73,10 +74,8 @@ class WorkstationUserGroup extends CommonObject
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$obj->table_element.' WHERE fk_workstation = '.$fk_workstation; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$obj->table_element.' WHERE fk_workstation = '.$fk_workstation;
$resql = $db->query($sql); $resql = $db->query($sql);
if(empty($resql)) return 0; if (empty($resql)) return 0;
return 1; return 1;
} }
} }

View File

@ -161,15 +161,10 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'confirm_enable' && $confirm == "yes" && $permissiontoadd) { if ($action == 'confirm_enable' && $confirm == "yes" && $permissiontoadd) {
if (!empty($object->id)) $object->setStatus(1);
if(!empty($object->id)) $object->setStatus(1);
} elseif ($action == 'confirm_disable' && $confirm == "yes" && $permissiontoadd) { } elseif ($action == 'confirm_disable' && $confirm == "yes" && $permissiontoadd) {
if (!empty($object->id)) $object->setStatus(0);
if(!empty($object->id)) $object->setStatus(0);
} }
} }
@ -418,11 +413,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
//$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
//unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_project']); // Hide field already shown in banner
//unset($object->fields['fk_soc']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner
if($object->type === 'MACHINE') $object->fields['nb_operators_required']['visible'] = 0; if ($object->type === 'MACHINE') $object->fields['nb_operators_required']['visible'] = 0;
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
// Groups // Groups
if($object->type !== 'MACHINE') { if ($object->type !== 'MACHINE') {
$toprint = array(); $toprint = array();
foreach ($object->usergroups as $id_group) { foreach ($object->usergroups as $id_group) {
$g = new UserGroup($db); $g = new UserGroup($db);
@ -435,7 +430,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
// Resources // Resources
if($object->type !== 'HUMAN') { if ($object->type !== 'HUMAN') {
$toprint = array(); $toprint = array();
foreach ($object->resources as $id_resource) { foreach ($object->resources as $id_resource) {
$r = new Dolresource($db); $r = new Dolresource($db);
@ -469,7 +464,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (empty($reshook)) if (empty($reshook))
{ {
// Modify // Modify
if ($permissiontoadd) { if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
@ -503,7 +497,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
print '</div>'."\n"; print '</div>'."\n";
} }
} }
// End of page // End of page

View File

@ -116,7 +116,7 @@ $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
if(in_array($key, array('type', 'status')) && GETPOST('search_'.$key, 'alpha') == -1) $search[$key] = ''; if (in_array($key, array('type', 'status')) && GETPOST('search_'.$key, 'alpha') == -1) $search[$key] = '';
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"