$title = _T("Transaction");
if ($trans->id != '') {
    $title .= ' (' . _T("modification") . ')';
} else {
    $title .= ' (' . _T("creation") . ')';
}
$tpl->assign('page_title', $title);
$tpl->assign('required', $required);
$tpl->assign('data', $transaction);
//TODO: remove
$tpl->assign('transaction', $trans);
$tpl->assign('error_detected', $error_detected);
$tpl->assign('success_detected', $success_detected);
$tpl->assign('require_calendar', true);
if ($trans->id != '') {
    $contribs = new Contributions();
    $tpl->assign('contribs', $contribs->getListFromTransaction($trans->id));
}
// members
$m = new Members();
$required_fields = array('id_adh', 'nom_adh', 'prenom_adh');
$members = $m->getList(false, $required_fields);
if (count($members) > 0) {
    foreach ($members as $member) {
        $pk = Adherent::PK;
        $sname = mb_strtoupper($member->nom_adh, 'UTF-8') . ' ' . ucwords(mb_strtolower($member->prenom_adh, 'UTF-8'));
        $adh_options[$member->{$pk}] = $sname;
    }
    $tpl->assign('adh_options', $adh_options);
}
// - declare dynamic fields for display
Beispiel #2
0
 /**
  * Remove transaction (and all associated contributions) from database
  *
  * @param boolean $transaction Activate transaction mode (defaults to true)
  *
  * @return boolean
  */
 public function remove($transaction = true)
 {
     global $zdb;
     try {
         if ($transaction) {
             $zdb->connection->beginTransaction();
         }
         //remove associated contributions if needeed
         if ($this->getDispatchedAmount() > 0) {
             $c = new Contributions();
             $clist = $c->getListFromTransaction($this->_id);
             $cids = array();
             foreach ($clist as $cid) {
                 $cids[] = $cid->id;
             }
             $rem = $c->removeContributions($cids, false);
         }
         //remove transaction itself
         $delete = $zdb->delete(self::TABLE);
         $delete->where(self::PK . ' = ' . $this->_id);
         $zdb->execute($delete);
         if ($transaction) {
             $zdb->connection->commit();
         }
         return true;
     } catch (\Exception $e) {
         if ($transaction) {
             $zdb->connection->rollBack();
         }
         Analog::log('An error occured trying to remove transaction #' . $this->_id . ' | ' . $e->getMessage(), Analog::ERROR);
         return false;
     }
 }