Exclude GLOBAL system from customer tab display
GLOBAL types (buildings) are now available in all system tabs via fetchAllBySystem(), but the GLOBAL system itself should not appear as a separate tab for customers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
06f8bc8fde
commit
411a48d577
2 changed files with 31 additions and 12 deletions
|
|
@ -82,6 +82,7 @@ $sql = "SELECT ss.rowid, ss.fk_system, s.code, s.label, s.picto, s.color
|
||||||
FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system ss
|
FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system ss
|
||||||
JOIN ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system s ON s.rowid = ss.fk_system
|
JOIN ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system s ON s.rowid = ss.fk_system
|
||||||
WHERE ss.fk_soc = ".((int) $id)." AND (ss.fk_contact IS NULL OR ss.fk_contact = 0) AND ss.active = 1 AND s.active = 1
|
WHERE ss.fk_soc = ".((int) $id)." AND (ss.fk_contact IS NULL OR ss.fk_contact = 0) AND ss.active = 1 AND s.active = 1
|
||||||
|
AND s.code != 'GLOBAL'
|
||||||
ORDER BY s.position ASC";
|
ORDER BY s.position ASC";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
|
@ -156,11 +157,15 @@ if ($action == 'add' && $permissiontoadd) {
|
||||||
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
||||||
$anlage->status = 1;
|
$anlage->status = 1;
|
||||||
|
|
||||||
// Get type for system ID
|
// Get type - but keep current system for GLOBAL types (buildings)
|
||||||
$type = new AnlageType($db);
|
$type = new AnlageType($db);
|
||||||
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
||||||
|
// Only change system if type is NOT a global type
|
||||||
|
// Global types (buildings) should stay in the current system
|
||||||
|
if ($type->system_code !== 'GLOBAL') {
|
||||||
$anlage->fk_system = $type->fk_system;
|
$anlage->fk_system = $type->fk_system;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// All fields come from dynamic fields now
|
// All fields come from dynamic fields now
|
||||||
$fieldValues = array();
|
$fieldValues = array();
|
||||||
|
|
@ -177,7 +182,7 @@ if ($action == 'add' && $permissiontoadd) {
|
||||||
$result = $anlage->create($user);
|
$result = $anlage->create($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||||
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$anlage->fk_system);
|
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$systemId);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
||||||
|
|
@ -187,16 +192,21 @@ if ($action == 'add' && $permissiontoadd) {
|
||||||
|
|
||||||
if ($action == 'update' && $permissiontoadd) {
|
if ($action == 'update' && $permissiontoadd) {
|
||||||
$anlage->fetch($anlageId);
|
$anlage->fetch($anlageId);
|
||||||
|
$systemIdBefore = $anlage->fk_system; // Remember original system
|
||||||
$anlage->label = GETPOST('label', 'alphanohtml');
|
$anlage->label = GETPOST('label', 'alphanohtml');
|
||||||
$anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type');
|
$anlage->fk_anlage_type = GETPOSTINT('fk_anlage_type');
|
||||||
$anlage->fk_parent = GETPOSTINT('fk_parent');
|
$anlage->fk_parent = GETPOSTINT('fk_parent');
|
||||||
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
||||||
|
|
||||||
// Get type for system ID
|
// Get type - but keep current system for GLOBAL types (buildings)
|
||||||
$type = new AnlageType($db);
|
$type = new AnlageType($db);
|
||||||
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
||||||
|
// Only change system if type is NOT a global type
|
||||||
|
// Global types (buildings) should stay in their current system
|
||||||
|
if ($type->system_code !== 'GLOBAL') {
|
||||||
$anlage->fk_system = $type->fk_system;
|
$anlage->fk_system = $type->fk_system;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// All fields come from dynamic fields now
|
// All fields come from dynamic fields now
|
||||||
$fieldValues = array();
|
$fieldValues = array();
|
||||||
|
|
@ -213,7 +223,7 @@ if ($action == 'update' && $permissiontoadd) {
|
||||||
$result = $anlage->update($user);
|
$result = $anlage->update($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||||
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$anlage->fk_system);
|
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$systemId);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ $sql = "SELECT ss.rowid, ss.fk_system, s.code, s.label, s.picto, s.color
|
||||||
FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system ss
|
FROM ".MAIN_DB_PREFIX."kundenkarte_societe_system ss
|
||||||
JOIN ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system s ON s.rowid = ss.fk_system
|
JOIN ".MAIN_DB_PREFIX."c_kundenkarte_anlage_system s ON s.rowid = ss.fk_system
|
||||||
WHERE ss.fk_soc = ".((int) $object->socid)." AND ss.fk_contact = ".((int) $id)." AND ss.active = 1 AND s.active = 1
|
WHERE ss.fk_soc = ".((int) $object->socid)." AND ss.fk_contact = ".((int) $id)." AND ss.active = 1 AND s.active = 1
|
||||||
|
AND s.code != 'GLOBAL'
|
||||||
ORDER BY s.position ASC";
|
ORDER BY s.position ASC";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
|
@ -160,11 +161,15 @@ if ($action == 'add' && $permissiontoadd) {
|
||||||
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
||||||
$anlage->status = 1;
|
$anlage->status = 1;
|
||||||
|
|
||||||
// Get type for system ID
|
// Get type - but keep current system for GLOBAL types (buildings)
|
||||||
$type = new AnlageType($db);
|
$type = new AnlageType($db);
|
||||||
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
||||||
|
// Only change system if type is NOT a global type
|
||||||
|
// Global types (buildings) should stay in the current system
|
||||||
|
if ($type->system_code !== 'GLOBAL') {
|
||||||
$anlage->fk_system = $type->fk_system;
|
$anlage->fk_system = $type->fk_system;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dynamic fields
|
// Dynamic fields
|
||||||
$fieldValues = array();
|
$fieldValues = array();
|
||||||
|
|
@ -180,7 +185,7 @@ if ($action == 'add' && $permissiontoadd) {
|
||||||
$result = $anlage->create($user);
|
$result = $anlage->create($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||||
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$anlage->fk_system);
|
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$systemId);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
||||||
|
|
@ -201,11 +206,15 @@ if ($action == 'update' && $permissiontoadd) {
|
||||||
$anlage->installation_date = dol_mktime(0, 0, 0, GETPOSTINT('installation_datemonth'), GETPOSTINT('installation_dateday'), GETPOSTINT('installation_dateyear'));
|
$anlage->installation_date = dol_mktime(0, 0, 0, GETPOSTINT('installation_datemonth'), GETPOSTINT('installation_dateday'), GETPOSTINT('installation_dateyear'));
|
||||||
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
$anlage->note_private = isset($_POST['note_private']) ? $_POST['note_private'] : '';
|
||||||
|
|
||||||
// Get type for system ID
|
// Get type - but keep current system for GLOBAL types (buildings)
|
||||||
$type = new AnlageType($db);
|
$type = new AnlageType($db);
|
||||||
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
if ($type->fetch($anlage->fk_anlage_type) > 0) {
|
||||||
|
// Only change system if type is NOT a global type
|
||||||
|
// Global types (buildings) should stay in their current system
|
||||||
|
if ($type->system_code !== 'GLOBAL') {
|
||||||
$anlage->fk_system = $type->fk_system;
|
$anlage->fk_system = $type->fk_system;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dynamic fields
|
// Dynamic fields
|
||||||
$fieldValues = array();
|
$fieldValues = array();
|
||||||
|
|
@ -221,7 +230,7 @@ if ($action == 'update' && $permissiontoadd) {
|
||||||
$result = $anlage->update($user);
|
$result = $anlage->update($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||||
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$anlage->fk_system);
|
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&system='.$systemId);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
setEventMessages($anlage->error, $anlage->errors, 'errors');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue