$error_detected[] = _T("- The name field cannot be void.");
     } else {
         $field_name = $_POST["field_name"];
         $field_perm = $_POST["field_perm"];
         $field_type = $_POST["field_type"];
         $field_required = $_POST["field_required"];
         $field_pos = $_POST["field_pos"];
         $query = "SELECT COUNT(*) + 1 AS idx\n\t\t\t\t\t  FROM {$field_types_table}\n\t\t\t\t\t  WHERE field_form={$quoted_form_name}";
         $idx = db_get_one($DB, $query, $error_detected);
         if ($idx != false) {
             $DB->StartTrans();
             $quoted_field_name = $DB->qstr($field_name, get_magic_quotes_gpc());
             $query = "INSERT INTO {$field_types_table}\n\t\t\t\t\t\t    (field_index, field_form, field_name, field_perm, field_type, field_required, field_pos)\n\t\t\t\t\t\t  VALUES ({$idx}, {$quoted_form_name}, {$quoted_field_name}, {$field_perm}, {$field_type}, {$field_required}, {$field_pos})";
             db_execute($DB, $query, $error_detected);
             if ($field_type != $field_type_separator && count($error_detected) == 0) {
                 $field_id = get_last_auto_increment($DB, $field_types_table, "field_id", $error_detected);
                 header("location: editer_champ.php?form={$form_name}&id={$field_id}");
             }
             if ($field_name != '') {
                 add_dynamic_translation($DB, $field_name, $error_detected);
             }
             $DB->CompleteTrans();
         }
     }
 } else {
     $action = "";
     $field_id = "";
     foreach (array("del", "up", "down") as $varname) {
         if (isset($_GET[$varname]) && is_numeric($_GET[$varname])) {
             $action = $varname;
             $field_id = (int) $_GET[$varname];
         }
     }
 }
 // missing required fields?
 while (list($key, $val) = each($required)) {
     if (!isset($disabled[$key]) && (!isset($adherent[$key]) || trim($adherent[$key]) == '')) {
         $error_detected[] = _T("- Mandatory field empty.") . " ({$key})";
     }
 }
 if (count($error_detected) == 0) {
     if ($adherent["id_adh"] == "") {
         $requete = "INSERT INTO " . PREFIX_DB . "adherents\n\t\t\t\t(" . substr($insert_string_fields, 1) . ")\n\t\t\t\tVALUES (" . substr($insert_string_values, 1) . ")";
         if (!$DB->Execute($requete)) {
             print substr($insert_string_values, 1) . ": " . $DB->ErrorMsg();
         }
         $adherent['id_adh'] = get_last_auto_increment($DB, PREFIX_DB . "adherents", "id_adh");
         // to allow the string to be extracted for translation
         $foo = _T("Member card added");
         // logging
         //nom_adh and prenom_adh is not sent when form is used by a simple user
         //dblog('Member card updated:',strtoupper($_POST["nom_adh"]).' '.$_POST["prenom_adh"], $requete);
         dblog('Member card updated:', strtoupper($_POST["login_adh"]), $requete);
     } else {
         $requete = "UPDATE " . PREFIX_DB . "adherents\n                                            SET " . substr($update_string, 1) . "\n                                            WHERE id_adh=" . $adherent['id_adh'];
         $DB->Execute($requete);
         // to allow the string to be extracted for translation
         $foo = _T("Member card updated:");
         // logging
         //nom_adh and prenom_adh is not sent when form is used by a simple user
         //dblog('Member card updated:',strtoupper($_POST["nom_adh"]).' '.$_POST["prenom_adh"], $requete);
         dblog('Member card updated:', strtoupper($_POST["login_adh"]), $requete);
         $missing_amount = missing_contrib_amount($DB, $contribution['trans_id'], $error_detected);
         if ($missing_amount < $contribution['montant_cotis']) {
             $error_detected[] = _T("-  Sum of all contributions exceed corresponding transaction amount.");
         } else {
             $missing_amount -= $contribution['montant_cotis'];
         }
     }
 }
 if (count($error_detected) == 0) {
     //Get user's login to put it in the logs
     $query = 'SELECT login_adh FROM ' . PREFIX_DB . 'adherents WHERE id_adh=' . $contribution['id_adh'];
     $login = $DB->GetOne($query);
     if ($contribution["id_cotis"] == "") {
         $requete = "INSERT INTO " . PREFIX_DB . "cotisations\n\t\t\t\t(" . substr($insert_string_fields, 1) . ")\n\t\t\t\tVALUES (" . substr($insert_string_values, 1) . ")";
         if (db_execute($DB, $requete, $error_detected)) {
             $contribution['id_cotis'] = get_last_auto_increment($DB, PREFIX_DB . "cotisations", "id_cotis");
             // to allow the string to be extracted for translation
             $foo = _T("Contribution added");
             // logging
             dblog('Contribution added', strtoupper($login), $requete);
         }
     } else {
         $requete = "UPDATE " . PREFIX_DB . "cotisations\n                                            SET " . substr($update_string, 1) . "\n                                            WHERE id_cotis=" . $contribution['id_cotis'];
         if (db_execute($DB, $requete, $error_detected)) {
             // to allow the string to be extracted for translation
             $foo = _T("Contribution updated");
             // logging
             dblog('Contribution updated', strtoupper($login), $requete);
         }
     }
     // dynamic fields
     } else {
         if ($contrib_amount > $transaction['trans_amount']) {
             $error_detected[] = _T("-  Sum of all contributions exceed corresponding transaction amount.");
         }
     }
     if ($transaction['id_adh'] <= 0) {
         $error_detected[] = _T("- No originator selected (register a non-member first if necessary).");
     }
 }
 if (count($error_detected) == 0) {
     if ($transaction["trans_id"] == "") {
         $requete = "INSERT INTO " . PREFIX_DB . "transactions\n\t\t\t(" . substr($insert_string_fields, 1) . ")\n\t\t\tVALUES (" . substr($insert_string_values, 1) . ")";
         if (!$DB->Execute($requete)) {
             print "{$requete}: " . $DB->ErrorMsg();
         }
         $transaction['trans_id'] = get_last_auto_increment($DB, PREFIX_DB . "transactions", "trans_id");
         // to allow the string to be extracted for translation
         $foo = _T("transaction added");
         // logging
         dblog('transaction added', '', $requete);
     } else {
         $requete = "UPDATE " . PREFIX_DB . "transactions\n\t\t\t\t    SET " . substr($update_string, 1) . "\n\t\t\t\t    WHERE trans_id=" . $transaction['trans_id'];
         $DB->Execute($requete);
         // to allow the string to be extracted for translation
         $foo = _T("transaction updated");
         // logging
         dblog('transaction updated', '', $requete);
     }
     // dynamic fields
     set_all_dynamic_fields($DB, 'trans', $transaction['trans_id'], $transaction['dyn']);
     if ($missing_amount > 0) {