From: root Date: Fri, 27 Jan 2023 10:28:16 +0000 (+0100) Subject: #0000179 Finaliser supprimer une operation reccurente X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=470170ddc9ab2005006f1281bbb5ddc85db981ca;p=www%2Fsyndic.git #0000179 Finaliser supprimer une operation reccurente --- diff --git a/app/compta/api/recurrent.php b/app/compta/api/recurrent.php index d0f6ba1..a663a24 100644 --- a/app/compta/api/recurrent.php +++ b/app/compta/api/recurrent.php @@ -124,7 +124,6 @@ _EOF; return Array(''); } $r_id = $r['r_id']; - error_log("Recurrent::update ".$r_id." update add entries ".$r['r_next']."\n"); foreach($entries as $entry) { $this->insertEntry($r_id,$entry); @@ -150,7 +149,7 @@ _EOF; } /** - * \brief, return the list of loans + * \brief, return the info for the given recurrent id. * TODO: Not sure if it's the right place */ function get($rid) @@ -165,6 +164,26 @@ _EOF; } return $res['records'][0]; } + + /** + * Delete the recurrent operation and its' entries + * : + * @param the recurrent id + * @return + */ + function remove($rid) + { + $q =<<<_EOF +DELETE from `RecurrentEntry` WHERE re_rec_id = {$rid}; +DELETE from `Recurrent` WHERE r_id = {$rid}; +_EOF; + try { + $res = $this->doQueryI($q); + } catch (Exception $e) { + error_log("Recurrent::remove ".$id." Failed ".$e->getMessage()); + } + return $res['records']; + } /** * * TODO: Not sure if it's the right place diff --git a/app/compta/controlers/recurrent.php b/app/compta/controlers/recurrent.php index ffb586b..8412c94 100644 --- a/app/compta/controlers/recurrent.php +++ b/app/compta/controlers/recurrent.php @@ -112,9 +112,13 @@ class Recurrent $this->_model->get($_id); if (\AEB::$REQUEST['confirm'] == 'yes') { - return new \compta\views\recurrent\Remove($this->_model); - } else; - return new \compta\views\recurrent\Remove($this->_model); + return new \compta\views\recurrent\Remove($this->_model); + } else + { + $this->_model->remove($_id); + require_once(controler::$basedir."/views/recurrent_index.php"); + return new \compta\views\recurrent\Index(); + } } /** * Get the details of the supplier account. diff --git a/app/compta/models/recurrent.php b/app/compta/models/recurrent.php index de87987..0ad1167 100644 --- a/app/compta/models/recurrent.php +++ b/app/compta/models/recurrent.php @@ -345,6 +345,21 @@ class Model implements \JsonSerializable } return [ 'des' => $this->des, 'lst' => $this->lst]; } + /** + * @brief remove recurrent and it's entries + * + */ + public function remove($id) + { + $_cfg = $this->_auth_cfg; + $rec = new \Recurrent( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + $this->id = $id; + $this->des = $rec->remove($id); + return [ 'id' => $id]; + } + /** * Required by JsonSerializable