Ejemplo n.º 1
0
$warning_detected = array();
//$confirm_detected = array();
// flagging required fields
$required = array('titre_adh' => 1, 'nom_adh' => 1, 'login_adh' => 1, 'mdp_adh' => 1, 'adresse_adh' => 1, 'cp_adh' => 1, 'ville_adh' => 1);
/**
* TODO
* - export to a class so users can dynamicaly modify this
*/
$disabled = array('id_adh' => 'disabled', 'date_crea_adh' => 'disabled', 'id_statut' => 'disabled', 'activite_adh' => 'disabled', 'bool_exempt_adh' => 'disabled', 'bool_admin_adh' => 'disabled', 'date_echeance' => 'disabled', 'info_adh' => 'disabled');
// DEBUT parametrage des champs
// On recupere de la base la longueur et les flags des champs
// et on initialise des valeurs par defaut
$update_string = '';
$insert_string_fields = '';
$insert_string_values = '';
$adherent['dyn'] = extract_posted_dynamic_fields($DB, $_POST, $disabled);
// checking posted values for 'regular' fields
if (isset($_POST["valid"])) {
    //check fields goodness
    $fields =& $DB->MetaColumns(PREFIX_DB . "adherents");
    while (list($key, $properties) = each($fields)) {
        $key = strtolower($key);
        if (isset($_POST[$key])) {
            $value = trim($_POST[$key]);
        } else {
            $value = '';
        }
        // if the field is enabled, check it
        if (!isset($disabled[$key])) {
            // fill up the adherent structure
            $adherent[$key] = htmlentities(stripslashes($value), ENT_QUOTES);
$tpl->assign("adh_selected", $adh_selected);
$type_selected = $contribution['id_cotis'] != '' || get_form_value("type_selected", 0);
$tpl->assign("type_selected", $type_selected);
$cotis_extension = 0;
if (isset($contribution['id_type_cotis'])) {
    $request = "SELECT cotis_extension\n\t\t\t    FROM " . PREFIX_DB . "types_cotisation\n\t\t\t    WHERE id_type_cotis = " . $contribution['id_type_cotis'];
    $cotis_extension = $DB->GetOne($request);
}
// initialize warning
$error_detected = array();
// flagging required fields
$required = array('montant_cotis' => 1, 'date_debut_cotis' => 1, 'date_fin_cotis' => $cotis_extension, 'id_type_cotis' => 1, 'id_adh' => 1);
// Validation
$contribution['dyn'] = array();
if (isset($_POST["valid"])) {
    $contribution['dyn'] = extract_posted_dynamic_fields($DB, $_POST, array());
    $update_string = '';
    $insert_string_fields = '';
    $insert_string_values = '';
    // checking posted values
    $fields =& $DB->MetaColumns(PREFIX_DB . "cotisations");
    while (list($key, $properties) = each($fields)) {
        $key = strtolower($key);
        if (isset($_POST[$key])) {
            $value = trim($_POST[$key]);
        } else {
            if ($key == 'date_enreg') {
                $value = $DB->DBDate(time());
            } else {
                if ($key == 'date_fin_cotis' && isset($_POST['duree_mois_cotis']) && isset($_POST['date_debut_cotis'])) {
                    $nmonths = trim($_POST['duree_mois_cotis']);
// initialize warning
$error_detected = array();
// flagging required fields
$required = array('trans_amount' => 1, 'trans_date' => 1, 'trans_desc' => 1);
function current_contrib_amount($DB, $trans_id, $error_detected)
{
    if (is_numeric($trans_id)) {
        $current_amount = $DB->GetOne("SELECT SUM(montant_cotis)\n\t\t\t\t\t\tFROM " . PREFIX_DB . "cotisations\n\t\t\t\t\t\tWHERE trans_id={$trans_id}");
        return $current_amount;
    }
    return 0;
}
// Validation
$transaction['dyn'] = array();
if (isset($_POST["valid"])) {
    $transaction['dyn'] = extract_posted_dynamic_fields($DB, $_POST, array());
    $update_string = '';
    $insert_string_fields = '';
    $insert_string_values = '';
    // checking posted values
    $fields =& $DB->MetaColumns(PREFIX_DB . "transactions");
    while (list($key, $properties) = each($fields)) {
        $key = strtolower($key);
        if (isset($_POST[$key])) {
            $value = trim($_POST[$key]);
        } else {
            $value = '';
        }
        // fill up the transaction structure
        $transaction[$key] = htmlentities(stripslashes($value), ENT_QUOTES);
        // now, check validity