Merge branch 'develop_new_workstation' of github.com:atm-gauthier/dolibarr into develop_new_workstation

This commit is contained in:
Gauthier PC portable 024 2020-12-21 12:38:59 +01:00
commit 4a2f38fcea
6 changed files with 27 additions and 36 deletions

View File

@ -77,7 +77,7 @@ class FormResource
* @param string $morecss More css
* @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
global $conf, $user, $langs;

View File

@ -233,8 +233,8 @@ class Workstation extends CommonObject
// Usergroups
$groups = GETPOST('groups');
if(empty($groups)) $groups = $this->usergroups; // createFromClone
if(!empty($groups)) {
if (empty($groups)) $groups = $this->usergroups; // createFromClone
if (!empty($groups)) {
foreach ($groups as $id_group) {
$ws_usergroup = new WorkstationUserGroup($db);
$ws_usergroup->fk_workstation = $id;
@ -246,8 +246,8 @@ class Workstation extends CommonObject
// Resources
$resources = GETPOST('resources');
if(empty($resources)) $resources = $this->resources; // createFromClone
if(!empty($resources)) {
if (empty($resources)) $resources = $this->resources; // createFromClone
if (!empty($resources)) {
foreach ($resources as $id_resource) {
$ws_resource = new WorkstationResource($db);
$ws_resource->fk_workstation = $id;
@ -490,7 +490,7 @@ class Workstation extends CommonObject
$resources = GETPOST('resources');
WorkstationResource::deleteAllResourcesOfWorkstation($this->id);
$this->resources=array();
if(!empty($resources)) {
if (!empty($resources)) {
foreach ($resources as $id_resource) {
$ws_resource = new WorkstationResource($this->db);
$ws_resource->fk_workstation = $this->id;
@ -677,7 +677,7 @@ class Workstation extends CommonObject
$this->status = $status;
if(empty($status)) $this->setDisabled($user, $notrigger);
if (empty($status)) $this->setDisabled($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;
@ -55,17 +56,17 @@ class WorkstationResource extends CommonObject
$resql = $db->query($sql);
$TRes = array();
if(!empty($resql)) {
while($res = $db->fetch_object($resql)) {
if (!empty($resql)) {
while ($res = $db->fetch_object($resql)) {
$TRes[] = $res->fk_resource;
}
}
return $TRes;
}
static public function deleteAllResourcesOfWorkstation($fk_workstation) {
static public function deleteAllResourcesOfWorkstation($fk_workstation)
{
global $db;
@ -73,10 +74,8 @@ class WorkstationResource extends CommonObject
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$obj->table_element.' WHERE fk_workstation = '.$fk_workstation;
$resql = $db->query($sql);
if(empty($resql)) return 0;
if (empty($resql)) return 0;
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;
@ -55,17 +56,17 @@ class WorkstationUserGroup extends CommonObject
$resql = $db->query($sql);
$TRes = array();
if(!empty($resql)) {
while($res = $db->fetch_object($resql)) {
if (!empty($resql)) {
while ($res = $db->fetch_object($resql)) {
$TRes[] = $res->fk_usergroup;
}
}
return $TRes;
}
static public function deleteAllGroupsOfWorkstation($fk_workstation) {
static public function deleteAllGroupsOfWorkstation($fk_workstation)
{
global $db;
@ -73,10 +74,8 @@ class WorkstationUserGroup extends CommonObject
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$obj->table_element.' WHERE fk_workstation = '.$fk_workstation;
$resql = $db->query($sql);
if(empty($resql)) return 0;
if (empty($resql)) return 0;
return 1;
}
}

View File

@ -161,15 +161,10 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
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) {
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
//unset($object->fields['fk_project']); // 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';
// Groups
if($object->type !== 'MACHINE') {
if ($object->type !== 'MACHINE') {
$toprint = array();
foreach ($object->usergroups as $id_group) {
$g = new UserGroup($db);
@ -435,7 +430,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
// Resources
if($object->type !== 'HUMAN') {
if ($object->type !== 'HUMAN') {
$toprint = array();
foreach ($object->resources as $id_resource) {
$r = new Dolresource($db);
@ -469,7 +464,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (empty($reshook))
{
// Modify
if ($permissiontoadd) {
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";
}
}
// End of page

View File

@ -116,7 +116,7 @@ $search = array();
foreach ($object->fields as $key => $val)
{
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"