loadLangs(array('admin', 'kundenkarte@kundenkarte')); // Security check if (!$user->admin) { accessforbidden(); } $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $id = GETPOSTINT('id'); $levelFilter = GETPOST('level_filter', 'alpha'); $buildingType = new BuildingType($db); $error = 0; // Actions if ($action == 'add' && $user->admin) { $buildingType->ref = GETPOST('ref', 'alphanohtml'); $buildingType->label = GETPOST('label', 'alphanohtml'); $buildingType->label_short = GETPOST('label_short', 'alphanohtml'); $buildingType->description = GETPOST('description', 'restricthtml'); $buildingType->fk_parent = GETPOSTINT('fk_parent'); $buildingType->level_type = GETPOST('level_type', 'alpha'); $buildingType->icon = GETPOST('icon', 'alphanohtml'); $buildingType->color = GETPOST('color', 'alphanohtml'); $buildingType->can_have_children = GETPOSTINT('can_have_children'); $buildingType->position = GETPOSTINT('position'); $buildingType->active = GETPOSTINT('active'); if (empty($buildingType->ref)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesaliases('Ref')), null, 'errors'); $error++; } if (empty($buildingType->label)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesaliases('Label')), null, 'errors'); $error++; } if (!$error) { $result = $buildingType->create($user); if ($result > 0) { setEventMessages($langs->trans('RecordCreatedSuccessfully'), null, 'mesgs'); header('Location: '.$_SERVER['PHP_SELF']); exit; } else { setEventMessages($buildingType->error, $buildingType->errors, 'errors'); } } $action = 'create'; } if ($action == 'update' && $user->admin) { $result = $buildingType->fetch($id); if ($result > 0) { // Don't allow editing ref of system types if (!$buildingType->is_system) { $buildingType->ref = GETPOST('ref', 'alphanohtml'); } $buildingType->label = GETPOST('label', 'alphanohtml'); $buildingType->label_short = GETPOST('label_short', 'alphanohtml'); $buildingType->description = GETPOST('description', 'restricthtml'); $buildingType->fk_parent = GETPOSTINT('fk_parent'); $buildingType->level_type = GETPOST('level_type', 'alpha'); $buildingType->icon = GETPOST('icon', 'alphanohtml'); $buildingType->color = GETPOST('color', 'alphanohtml'); $buildingType->can_have_children = GETPOSTINT('can_have_children'); $buildingType->position = GETPOSTINT('position'); $buildingType->active = GETPOSTINT('active'); $result = $buildingType->update($user); if ($result > 0) { setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs'); header('Location: '.$_SERVER['PHP_SELF']); exit; } else { setEventMessages($buildingType->error, $buildingType->errors, 'errors'); } } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->admin) { $result = $buildingType->fetch($id); if ($result > 0) { $result = $buildingType->delete($user); if ($result > 0) { setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs'); } else { setEventMessages($langs->trans($buildingType->error), $buildingType->errors, 'errors'); } } header('Location: '.$_SERVER['PHP_SELF']); exit; } // Load data for edit if (($action == 'edit' || $action == 'delete') && $id > 0) { $result = $buildingType->fetch($id); } /* * View */ $page_name = "BuildingTypesSetup"; llxHeader('', $langs->trans($page_name), '', '', 0, 0, '', '', '', 'mod-kundenkarte page-admin-building_types'); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_kundenkarte@kundenkarte'); print '
| '.$langs->trans('Ref').' | '; print ''.$langs->trans('Label').' | '; print ''.$langs->trans('LevelType').' | '; print ''.$langs->trans('Icon').' | '; print ''.$langs->trans('Color').' | '; print ''.$langs->trans('Position').' | '; print ''.$langs->trans('Active').' | '; print ''.$langs->trans('Actions').' | '; print '
| '.$type->ref; if ($type->is_system) { print ' '.$langs->trans('System').''; } print ' | '; // Label print ''; if ($type->icon) { print ' '; } print dol_escape_htmltag($type->label); if ($type->label_short) { print ' ('.$type->label_short.')'; } print ' | '; // Level Type print ''.$type->getLevelTypeLabel().' | '; // Icon print ''; if ($type->icon) { print ' '.$type->icon; } print ' | '; // Color print ''; if ($type->color) { print ' '.$type->color; } print ' | '; // Position print ''.$type->position.' | '; // Active print ''; print $type->active ? ''.$langs->trans('Yes').'' : ''.$langs->trans('No').''; print ' | '; // Actions print ''; print ''.img_edit().''; if (!$type->is_system) { print ' '.img_delete().''; } print ' | '; print '
| '.$langs->trans('NoRecordFound').' | |||||||