Fatal error: Call to undefined function beforeParseFunction() in C:\wamp\www\Trait_d_union\assets\snippets\eform\eform.inc.php on line 138
[[multiFormFunctions]] [!eForm? &formid=`contact` &to=`[email protected]` &subject=`Annonce Presse` &tpl=`formOne` &eFormOnBeforeFormParse=`beforeParseFunction` &eformOnBeforeMailSent=`beforeMailSentFunction` &report=`formReport` &thankyou=`FeedBackThanks`!]
[[FormInternet]] [!eForm? &formid=`contact_internet` &to=`[email protected] ` &subject=`Annonce Internet` &tpl=`formOneInternet` &eFormOnBeforeFormParse=`beforeParseFunction` &eformOnBeforeMailSent=`beforeMailSentFunction` &report=`formReportInternet` &thankyou=`FeedBackThanksInternet`!]

<?php
if(!function_exists("beforeParseFunction")){
//Display different form depending on session
function beforeParseFunction( &$fields, &$templates ){
global $_lang;
//which form should we load?
// $step is set in beforeMailSentFunction or comes from the hidden field
// we need to do both so that when we step back (eg. the back button of the browser)
// we still get the proper form
if(isset($_SESSION['formStep']))
$step = $_SESSION['formStep'];
else
$step = isset($_POST['formStep'])?$_POST['formStep']:1;
//Kill the session var as otherwise we can't go back to a previous step at all
unset($_SESSION['formStep']);
$tpl = $templates['tpl'];
// Replace form template when needed
switch($step){
case 1: //form not yet posted so use tpl as set in snippet call
return true;
case 2:
$replaceTpl = "multiForm2intenet";
break;
case 3:
$replaceTpl = "multiForm3internet";
break;
default: //should never get here
return false;
}
if($step>1)
if( $tmp=efLoadTemplate($replaceTpl) ) $tpl=$tmp; else $tpl = $_lang['ef_no_doc'] . " '$replaceTpl'";
//restore template in array
$templates['tpl']=$tpl;
return true;
}
}
if(!function_exists("beforeMailSentFunction")){
//store results in session and advance form
function beforeMailSentFunction(&$fields){
global $modx;
$step = isset($fields['formStep'])?$fields['formStep']:1;
switch($step){
case 1: //save values in session
$_SESSION['civilite'] = $fields['civilite'];
$_SESSION['name']= $fields['name'];
$_SESSION['prenom'] = $fields['prenom'];
$_SESSION['societe']= $fields['societe'];
$_SESSION['secteur']= $fields['secteur'];
$_SESSION['fonction']= $fields['fonction'];
$_SESSION['mail']= $fields['mail'];
$_SESSION['site']= $fields['site'];
$_SESSION['address']= $fields['address'];
$_SESSION['address2']= $fields['address2'];
$_SESSION['pc']= $fields['pc'];
$_SESSION['ville']= $fields['ville'];
$_SESSION['telephone']= $fields['telephone'];
$_SESSION['fax']= $fields['fax'];
$_SESSION['address3']= $fields['address3'];
$_SESSION['address4']= $fields['address4'];
$_SESSION['pc2']= $fields['pc2'];
$_SESSION['ville2']= $fields['ville2'];
$_SESSION['formStep'] = 2; //prepare next step
break;
case 2: //save values in session
$_SESSION['support']= $fields['support'];
$_SESSION['edition']= $fields['edition'];
$_SESSION['parution']= $fields['parution'];
$_SESSION['commentaire']= $fields['commentaire'];
$_SESSION['formStep'] = 3; //prepare next step
break;
case 3://last form
//from here we go to the report so we need to restore previous values
// into the fields array so they can be used in the report
$fields['civilite'] = $_SESSION['civilite'];
$fields['name'] = $_SESSION['name'];
$fields['prenom'] = $_SESSION['prenom'];
$fields['societe'] = $_SESSION['societe'];
$fields['secteur']= $_SESSION['secteur'];
$fields['fonction']= $_SESSION['fonction'];
$fields['mail']= $_SESSION['mail'];
$fields['site']= $_SESSION['site'];
$fields['address'] = $_SESSION['address'];
$fields['address2'] = $_SESSION['address2'];
$fields['pc'] = $_SESSION['pc'];
$fields['ville'] = $_SESSION['ville'];
$fields['telephone']= $_SESSION['telephone'];
$fields['fax']= $_SESSION['fax'];
$fields['address3'] = $_SESSION['address3'];
$fields['address4'] = $_SESSION['address4'];
$fields['pc2'] = $_SESSION['pc2'];
$fields['ville2'] = $_SESSION['ville2'];
$fields['support'] = $_SESSION['support'];
$fields['edition'] = $_SESSION['edition'];
$fields['parution'] = $_SESSION['parution'];
$fields['commentaire'] = $_SESSION['commentaire'];
return true; //return now and let eForm do it's thing
default: //should never get here
return false;
}
// except for the last step we clear the $_POST array
// and bypass eform and re-open the page with the next form
//unset($_POST); - doesn't work in php 4.3.xx
$_POST = array();
$modx->sendForward($modx->documentIdentifier);
return false; //
}
}
//return from snippet
return "";
?>