use Galette\Entity\Contribution;
use Galette\Entity\ContributionsTypes;
use Galette\Entity\Texts;
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;
}
$contrib = new Contribution();
//TODO: dynamic fields should be handled by Contribution object
$dyn_fields = new DynamicFields();
$id_cotis = get_numeric_form_value('id_cotis', '');
//first/second step: select member
$id_adh = get_numeric_form_value('id_adh', '');
//first/second step: select contribution type
$selected_type = get_form_value('id_type_cotis', 1);
//first/second step: transaction id
$trans_id = get_numeric_form_value('trans_id', '');
//mark first step has been passed
$type_selected = $id_cotis != null || get_form_value('type_selected', 0);
// flagging required fields for first step only
$required = array('id_type_cotis' => 1, 'id_adh' => 1, 'date_enreg' => 1);
$cotis_extension = 0;
// TODO: remove and remplace with $contrib->isCotis()
$disabled = array();
if ($type_selected && !($id_adh || $id_cotis)) {
Beispiel #2
0
 /**
  * Returns an array of fixed valued for a field of type 'choice'.
  *
  * @return void
  */
 private function _loadFixedValues()
 {
     global $zdb;
     try {
         $val_select = $zdb->select(DynamicFields::getFixedValuesTableName($this->id));
         $val_select->columns(array('val'))->order('id');
         $results = $zdb->execute($val_select);
         $this->values = array();
         if ($results) {
             foreach ($results as $val) {
                 $this->values[] = $val->val;
             }
         }
     } catch (\Exception $e) {
         Analog::log(__METHOD__ . ' | ' . $e->getMessage(), Analog::WARNING);
     }
 }
Beispiel #3
0
 * @since     Available since 0.62
 */
use Galette\Core\GaletteMail;
use Galette\Entity\DynamicFields;
use Galette\Entity\Adherent;
use Galette\Entity\FieldsConfig;
use Galette\Entity\Texts;
use Galette\Repository\Titles;
use Galette\Core\PasswordImage;
/** @ignore */
require_once 'includes/galette.inc.php';
if (!$preferences->pref_bool_selfsubscribe) {
    header('location:index.php');
    die;
}
$dyn_fields = new DynamicFields();
$member = new Adherent();
//mark as self membership
$member->setSelfMembership();
// flagging required fields
$fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
// flagging required fields invisible to members
$fc->setNotRequired('activite_adh');
$fc->setNotRequired('id_statut');
$required = $fc->getRequired();
// flagging fields visibility
$visibles = $fc->getVisibilities();
// disable some fields
$disabled = $member->disabled_fields;
// DEBUT parametrage des champs
// On recupere de la base la longueur et les flags des champs
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");
    } else {
        $success_detected[] = _T("Contribution has been successfully detached from current transaction");
Beispiel #5
0
/** @ignore */
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;
} else {
    if (!$login->isAdmin()) {
        header('location: gestion_adherents.php');
        die;
    }
}
$dyn_fields = new DynamicFields();
$all_forms = $dyn_fields->getFormsNames();
$form_name = get_form_value('form', '');
if (!isset($all_forms[$form_name])) {
    header('location: configurer_fiches.php');
    die;
}
$field_id = get_numeric_form_value("id", '');
if ($field_id == '') {
    header('location: configurer_fiches.php?form=' . $form_name);
    die;
}
$df = $dyn_fields->loadFieldType($field_id);
if ($df === false) {
    $error_detected[] = _T("Unable to retrieve field informations.");
}
Beispiel #6
0
    die;
}
if (isset($session['pdf_error']) && $session['pdf_error']) {
    $error_detected[] = $session['pdf_error_msg'];
    unset($session['pdf_error_msg']);
    unset($session['pdf_error']);
}
if (isset($session['lostpasswd_errors'])) {
    $error_detected = unserialize($session['lostpasswd_errors']);
    unset($session['lostpasswd_errors']);
}
if (isset($session['lostpasswd_success'])) {
    $success_detected = unserialize($session['lostpasswd_success']);
    unset($session['lostpasswd_success']);
}
$dyn_fields = new DynamicFields();
$deps = array('picture' => true, 'groups' => true, 'dues' => true, 'parent' => true, 'children' => true);
$member = new Adherent((int) $id_adh, $deps);
// flagging fields visibility
$fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
$visibles = $fc->getVisibilities();
if ($login->id != $id_adh && !$login->isAdmin() && !$login->isStaff()) {
    //check if requested member is part of managed groups
    $groups = $member->groups;
    $is_managed = false;
    foreach ($groups as $g) {
        if ($login->isGroupManager($g->getId())) {
            $is_managed = true;
            break;
        }
    }
Beispiel #7
0
 /**
  * Builds the SELECT statement
  *
  * @param int   $mode   the current mode (see self::SHOW_*)
  * @param array $fields fields list to retrieve
  * @param bool  $photos true if we want to get only members with photos
  *                      Default to false, only relevant for SHOW_PUBLIC_LIST
  * @param bool  $count  true if we want to count members, defaults to false
  *
  * @return Select SELECT statement
  */
 private function _buildSelect($mode, $fields, $photos, $count = false)
 {
     global $zdb, $login;
     try {
         $fieldsList = $fields != null ? !is_array($fields) || count($fields) < 1 ? (array) '*' : $fields : (array) '*';
         $select = $zdb->select(self::TABLE, 'a');
         $select->columns($fieldsList);
         $select->quantifier('DISTINCT');
         switch ($mode) {
             case self::SHOW_STAFF:
             case self::SHOW_LIST:
             case self::SHOW_ARRAY_LIST:
                 $select->join(array('p' => PREFIX_DB . Status::TABLE), 'a.' . Status::PK . '=p.' . Status::PK, array());
                 break;
             case self::SHOW_EXPORT:
                 //basically the same as above, but without any fields
                 $select->join(array('p' => PREFIX_DB . Status::TABLE), 'a.' . Status::PK . '=p.' . Status::PK, array());
                 break;
             case self::SHOW_MANAGED:
                 $select->join(array('p' => PREFIX_DB . Status::TABLE), 'a.' . Status::PK . '=p.' . Status::PK)->join(array('gr' => PREFIX_DB . Group::GROUPSUSERS_TABLE), 'a.' . Adherent::PK . '=gr.' . Adherent::PK, array())->join(array('m' => PREFIX_DB . Group::GROUPSMANAGERS_TABLE), 'gr.' . Group::PK . '=m.' . Group::PK, array())->where('m.' . Adherent::PK . ' = ' . $login->id);
             case self::SHOW_PUBLIC_LIST:
                 if ($photos) {
                     $select->join(array('p' => PREFIX_DB . Picture::TABLE), 'a.' . self::PK . '= p.' . self::PK);
                 }
                 break;
         }
         //check for contributions filtering
         if ($this->_filters instanceof AdvancedMembersList && $this->_filters->withinContributions()) {
             $select->join(array('ct' => PREFIX_DB . Contribution::TABLE), 'ct.' . self::PK . '=a.' . self::PK, array(), $select::JOIN_LEFT);
         }
         //check if there are dynamic fields in the filter
         $hasDf = false;
         $hasCdf = false;
         $cdfs = array();
         $cdfcs = array();
         if ($this->_filters instanceof AdvancedMembersList && $this->_filters->free_search && count($this->_filters->free_search) > 0 && !isset($this->_filters->free_search['empty'])) {
             $free_searches = $this->_filters->free_search;
             foreach ($free_searches as $fs) {
                 if (strpos($fs['field'], 'dyn_') === 0) {
                     $hasDf = true;
                 }
                 if (strpos($fs['field'], 'dync_') === 0) {
                     $hasCdf = true;
                     $cdfs[] = str_replace('dync_', '', $fs['field']);
                 }
             }
         }
         //check if there are dynamic fields for contributions in filter
         $hasDfc = false;
         $hasCdfc = false;
         if ($this->_filters instanceof AdvancedMembersList && $this->_filters->withinContributions()) {
             if ($this->_filters->contrib_dynamic && count($this->_filters->contrib_dynamic) > 0 && !isset($this->_filters->contrib_dynamic['empty'])) {
                 $hasDfc = true;
                 //check if there are dynamic fields in the filter
                 foreach ($this->_filters->contrib_dynamic as $k => $cd) {
                     if (is_array($cd)) {
                         $hasCdfc = true;
                         $cdfcs[] = $k;
                     }
                 }
             }
         }
         if ($hasDf === true || $hasCdf === true) {
             $select->join(array('df' => PREFIX_DB . DynamicFields::TABLE), 'df.item_id=a.' . self::PK, array(), $select::JOIN_LEFT);
         }
         if ($hasDfc === true || $hasCdfc === true) {
             $select->join(array('dfc' => PREFIX_DB . DynamicFields::TABLE), 'dfc.item_id=ct.' . Contribution::PK, array(), $select::JOIN_LEFT);
         }
         if ($hasCdf === true || $hasCdfc === true) {
             $cdf_field = 'cdf.id';
             if (TYPE_DB === 'pgsql') {
                 $cdf_field .= '::text';
             }
             foreach ($cdfs as $cdf) {
                 $rcdf_field = str_replace('cdf.', 'cdf' . $cdf . '.', $cdf_field);
                 $select->join(array('cdf' . $cdf => DynamicFields::getFixedValuesTableName($cdf, true)), $rcdf_field . '=df.field_val', array(), $select::JOIN_LEFT);
             }
             $cdf_field = 'cdfc.id';
             if (TYPE_DB === 'pgsql') {
                 $cdf_field .= '::text';
             }
             foreach ($cdfcs as $cdf) {
                 $rcdf_field = str_replace('cdfc.', 'cdfc' . $cdf . '.', $cdf_field);
                 $select->join(array('cdfc' . $cdf => DynamicFields::getFixedValuesTableName($cdf, true)), $rcdf_field . '=dfc.field_val', array(), $select::JOIN_LEFT);
             }
         }
         if ($mode == self::SHOW_LIST || $mode == self::SHOW_MANAGED) {
             if ($this->_filters !== false) {
                 $this->_buildWhereClause($select);
             }
             $select->order($this->_buildOrderClause($fields));
         } else {
             if ($mode == self::SHOW_PUBLIC_LIST) {
                 $select->where('activite_adh = true')->where('bool_display_info = true');
                 $select->where->greaterThan('date_echeance', date('Y-m-d'))->or->equalTo('bool_exempt_adh', true);
             }
         }
         if ($mode === self::SHOW_STAFF) {
             $select->where->lessThan('p.priorite_statut', self::NON_STAFF_MEMBERS);
         }
         if ($count) {
             $this->_proceedCount($select);
         }
         //Fix for #687, but only for MySQL (break on PostgreSQL)
         //$select->group('a.' . Adherent::PK);
         return $select;
     } catch (\Exception $e) {
         Analog::log('Cannot build SELECT clause for members | ' . $e->getMessage(), Analog::WARNING);
         return false;
     }
 }
/** @ignore */
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;
} else {
    if (!$login->isAdmin()) {
        header('location: gestion_adherents.php');
        die;
    }
}
$dyn_fields = new DynamicFields();
$all_forms = $dyn_fields->getFormsNames();
$form_name = isset($_GET['form']) ? $_GET['form'] : 'adh';
if (isset($_POST['form']) && trim($_POST['form']) != '') {
    $form_name = $_POST['form'];
}
if (!isset($all_forms[$form_name])) {
    $form_name = '';
}
$field_type_names = $dyn_fields->getFieldsTypesNames();
if ($form_name == '') {
    $form_title = '';
} else {
    $form_title = $all_forms[$form_name];
    if (isset($_POST['valid'])) {
        if ($_POST['field_type'] != DynamicFields::SEPARATOR && (!isset($_POST['field_name']) || $_POST['field_name'] == '')) {
Beispiel #9
0
}
if (isset($warning_detected)) {
    $tpl->assign('warning_detected', $warning_detected);
}
//we want only visibles fields
$fields = $members_fields;
$fc = new FieldsConfig(Adherent::TABLE, $members_fields, $members_fields_cats);
$visibles = $fc->getVisibilities();
foreach ($fields as $k => $f) {
    if ($visibles[$k] == 0) {
        unset($fields[$k]);
    }
}
$tpl->assign('search_fields', $fields);
//dynamic fields
$df = new DynamicFields();
$dynamic_fields = $df->prepareForDisplay('adh', array(), array(), 0);
$tpl->assign('dynamic_fields', $dynamic_fields);
$cdynamic_fields = $df->prepareForDisplay('contrib', array(), array(), 0);
$tpl->assign('cdynamic_fields', $cdynamic_fields);
//Status
$statuts = new Galette\Entity\Status();
$tpl->assign('statuts', $statuts->getList());
//Contributions types
$ct = new Galette\Entity\ContributionsTypes();
$tpl->assign('contributions_types', $ct->getList());
//Payments types
$pt = array(Contribution::PAYMENT_OTHER => _T("Other"), Contribution::PAYMENT_CASH => _T("Cash"), Contribution::PAYMENT_CREDITCARD => _T("Credit card"), Contribution::PAYMENT_CHECK => _T("Check"), Contribution::PAYMENT_TRANSFER => _T("Transfer"), Contribution::PAYMENT_PAYPAL => _T("Paypal"));
$tpl->assign('payments_types', $pt);
$tpl->assign('filters', $filters);
$filters->setTplCommonsFilters($preferences, $tpl);