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);
}
/**
- * \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)
}
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
$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.
}
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