query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($id_module)); } $dbo->update('an_anagrafiche', [ 'id_module' => post('module'), 'name' => post('name'), 'clause' => post('clause'), 'pattern' => $pattern, 'note' => post('note'), 'position' => post('pisition'), 'predefined' => $predefined, ], ['id' => $id_record]); $_SESSION['infos'][] = tr('Modifiche salvate correttamente'); break; case 'add': $pattern = str_contains(post('pattern'), '#') ? post('pattern') : '####'; $predefined = post('predefined'); if (empty(Modules::getSegments($id_module))) { $predefined = 1; } if ($predefined) { $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($id_module)); } $dbo->insert('zz_segments', [ 'id_module' => post('module'), 'name' => post('name'), 'clause' => '1=1', 'pattern' => $pattern, 'note' => post('note'), 'predefined' => $predefined, ]); $id_record = $dbo->last_inserted_id(); $_SESSION['infos'][] = tr('Nuovo segmento aggiunto'); break; case 'delete': $dbo->query('DELETE FROM zz_segments WHERE id='.prepare($id_record)); // TODO // eliminare riferimento sulle fatture eventuali collegate a questo segmento? $_SESSION['infos'][] = tr('Segmento eliminato'); break; }