use Galette\Entity\Adherent; use Galette\Entity\DynamicFields; use Galette\Entity\Transaction; use Galette\Entity\Contribution; use Galette\Repository\Contributions; use Galette\Repository\Members; require_once 'includes/galette.inc.php'; if (!$login->isLogged()) { header('location: index.php'); die; } if (!$login->isAdmin() && !$login->isStaff()) { header('location: voir_adherent.php'); die; } $trans = new Transaction(); //TODO: dynamic fields should be handled by Transaction object $dyn_fields = new DynamicFields(); // new or edit $trans_id = get_numeric_form_value("trans_id", ''); $transaction['trans_id'] = get_numeric_form_value("trans_id", ''); $transaction['trans_amount'] = get_numeric_form_value("trans_amount", ''); $transaction['trans_date'] = get_form_value("trans_date", ''); $transaction['trans_desc'] = get_form_value("trans_desc", ''); $transaction['id_adh'] = get_numeric_form_value("id_adh", ''); // flagging required fields $required = array('trans_amount' => 1, 'trans_date' => 1, 'trans_desc' => 1, 'id_adh' => 1); $disabled = array(); if (isset($_GET['detach'])) { if (!Contribution::unsetTransactionPart($trans_id, $_GET['detach'])) { $error_detected[] = _T("Unable to detach contribution from transaction");
/** * Remove specified transactions * * @param interger|array $ids Transactions identifiers to delete * * @return boolean */ public function removeTransactions($ids) { global $zdb, $hist; $list = array(); if (is_numeric($ids)) { //we've got only one identifier $list[] = $ids; } else { $list = $ids; } if (is_array($list)) { $res = true; try { $zdb->connection->beginTransaction(); $select = $zdb->select(self::TABLE); $select->where->in(self::PK, $list); $results = $zdb->execute($select); foreach ($results as $transaction) { $c = new Transaction($transaction); $res = $c->remove(false); if ($res === false) { throw new \Exception(); } } $zdb->connection->commit(); $hist->add("Transactions deleted (" . print_r($list, true) . ')'); } catch (\Exception $e) { $zdb->connection->rollBack(); Analog::log('An error occured trying to remove transactions | ' . $e->getMessage(), Analog::ERROR); return false; } } else { //not numeric and not an array: incorrect. Analog::log('Asking to remove transaction, but without providing ' . 'an array or a single numeric value.', Analog::WARNING); return false; } }