@@ -226,11 +226,12 @@ function (Filter\Condition $condition) {
226226                    $ dbupdate ('contact ' , [
227227                        'full_name '              => $ data'full_name ' ],
228228                        'username '               => $ data'username ' ] ?? null ,
229-                         'default_channel_id '     => $ this getChannelId ($ data'default_channel ' ])
229+                         'default_channel_id '     => $ this getChannelId ($ data'default_channel ' ]), 
230230                    ], ['id = ? '  => $ contactId
231231
232-                     $ dbdelete ('contact_address ' , ['contact_id = ? '  => $ contactId
233-                     $ dbdelete ('contactgroup_member ' , ['contact_id = ? '  => $ contactId
232+                     $ markAsDeleted'deleted '  => 'y ' ];
233+                     $ dbupdate ('contact_address ' , $ markAsDeleted'contact_id = ? '  => $ contactId'deleted = ? '  => 'n ' ]);
234+                     $ dbupdate ('contactgroup_member ' , $ markAsDeleted'contact_id = ? '  => $ contactId'deleted = ? '  => 'n ' ]);
234235
235236                    if  (! empty ($ data'addresses ' ])) {
236237                        $ this addAddresses ($ contactId$ data'addresses ' ]);
@@ -497,9 +498,26 @@ private function addAddresses(int $contactId, array $addresses): void
497498     */ 
498499    private  function  removeContact (int  $ idvoid 
499500    {
500-         Database::get ()->delete ('contactgroup_member ' , ['contact_id = ? '  => $ id
501-         Database::get ()->delete ('contact_address ' , ['contact_id = ? '  => $ id
502-         Database::get ()->delete ('contact ' , ['id = ? '  => $ id
501+         $ dbget ();
502+         $ markAsDeleted'deleted '  => 'y ' ];
503+ 
504+         $ dbupdate (
505+             'rotation_member ' ,
506+             $ markAsDeleted'position '  => null ],
507+             ['contact_id = ? '  => $ id'deleted = ? '  => 'n ' ]
508+         );
509+ 
510+         $ dbupdate (
511+             'rule_escalation_recipient ' ,
512+             $ markAsDeleted
513+             ['contact_id = ? '  => $ id'deleted = ? '  => 'n ' ]
514+         );
515+ 
516+         $ dbupdate ('contactgroup_member ' , $ markAsDeleted'contact_id = ? '  => $ id'deleted = ? '  => 'n ' ]);
517+         $ dbupdate ('contact_address ' , $ markAsDeleted'contact_id = ? '  => $ id'deleted = ? '  => 'n ' ]);
518+         $ dbupdate ('contact ' , $ markAsDeleted'id = ? '  => $ id
519+ 
520+         //TODO: properly remove rotations|escalations with no members as in form 
503521    }
504522
505523    /** 
0 commit comments