loadLangs(array('kundenkarte@kundenkarte')); $action = GETPOST('action', 'aZ09'); $systemId = GETPOSTINT('system_id'); $response = array('success' => false, 'error' => ''); // Security check if (!$user->hasRight('kundenkarte', 'read')) { $response['error'] = $langs->trans('ErrorPermissionDenied'); echo json_encode($response); exit; } $busbarType = new BusbarType($db); switch ($action) { case 'list': // Get all busbar types for a system (or all if system_id = 0) $types = $busbarType->fetchAllBySystem($systemId, 1); $result = array(); foreach ($types as $t) { $result[] = array( 'id' => $t->id, 'ref' => $t->ref, 'label' => $t->label, 'label_short' => $t->label_short, 'phases' => $t->phases, 'phases_config' => $t->phases_config ? json_decode($t->phases_config, true) : null, 'num_lines' => $t->num_lines, 'color' => $t->color, 'default_color' => $t->default_color, 'line_height' => $t->line_height, 'line_spacing' => $t->line_spacing, 'position_default' => $t->position_default, 'fk_system' => $t->fk_system, 'system_label' => $t->system_label ); } $response['success'] = true; $response['types'] = $result; break; default: $response['error'] = 'Unknown action'; break; } echo json_encode($response);