require_once "mainconf_asian.php";
// Variabili globali di configurazione
$defLang = "it";
$viewForm = 0;
$openLabelDescRep = '
';
$closeLabelDescRep = '';
$form["CHOOSE_ESTIMATE"] = 0;
$form["ESTIMATE_TYPE_1"] = 1;
$form["ESTIMATE_TYPE_2"] = 2;
$action["CHECK_FORM"] = 0;
$action["SEND_FORM"] = 0;
$action["SHOW_FORM"] = 0;
$action["SHOW_END_MSG"] = 0;
$error = 0;
if(isset($_POST["invia_form"])){
$action["CHECK_FORM"] = 1;
}
else {
$action["SHOW_FORM"] = 1;
}
// Imposta lingua
$lang = $defLang;
if(isset($_GET["lang"])) $lang = $_GET["lang"];
if(isset($_POST["lang"])) $lang = $_POST["lang"];
$labels = &$fieldLabels[$lang];
// CONTROLLO INPUT
if($action["CHECK_FORM"]){
if($_POST["tipo_preventivo"]==$form["ESTIMATE_TYPE_1"]){
$reqField = array(0,1,2,3,6,7,8,9,10);
}
if($_POST["tipo_preventivo"]==$form["ESTIMATE_TYPE_2"]){
$reqField = array(0,1,2,3);
}
foreach($reqField as $i){
$fldName = $formFieldsList[$_POST["tipo_preventivo"]][$i];
if(empty($_POST[$fldName])){
$error++;
$errorMsg = htmlentities($errorMessage[$lang][0]);
break;
}
}
// Inserimento allegato
if(!$error>0 && $_FILES["allegato_testo_traduzione"]["name"]!=""){
$mimeType = $_FILES["allegato_testo_traduzione"]["type"];
$tempName = $_FILES["allegato_testo_traduzione"]['tmp_name'];
$fileName = $_FILES["allegato_testo_traduzione"]["name"];
$file = $uploadDir.$_FILES["allegato_testo_traduzione"]["name"];
// Controlla se il file abbia un mime type abilitato
$typeValid = 0;
foreach($allowedType as $type){
if($mimeType==$type){
$typeValid = 1;
break;
}
}
if(!$typeValid){
$error++;
$errorMsg = htmlentities($errorMessage[$lang][1]);
}
}
if(!$error>0)
$action["SEND_FORM"] = 1;
else
$action["SHOW_FORM"] = 1;
}
// INVIO DATI FORM
if($action["SEND_FORM"]){
$mailBody = "";
foreach ($formFieldsList[$_POST["tipo_preventivo"]] As $field){
if($field=="allegato_testo_traduzione" || $field=="MAX_FILE_SIZE") continue;
if(ereg("(.+)
".$body.""; $action["SHOW_END_MSG"] = 0;*/ } if($action["SHOW_END_MSG"]){ $tmpl = new patTemplate(); $tmpl->setBasedir( "templates" ); $tmpl->readTemplatesFromFile("endmsg.tmpl.htm"); if($error>0) $tmpl->addVar("end","MESSAGE",$errorMessage[$lang][2]); else $tmpl->addVar("end","MESSAGE",$successMessage[$lang]); $tmpl->setAttribute("leftmenu_".$lang,"visibility","visible"); $tmpl->displayParsedTemplate(); } // VISUALIZZAZIONE FORM if($action["SHOW_FORM"]){ // Inizializzazione template $tmpl = new patTemplate(); $tmpl->setBasedir( "templates" ); $tmpl->readTemplatesFromFile("form_asian_preventivi.tmpl.htm"); $tmpl->addGlobalVar("LANG_N","lang"); $tmpl->addGlobalVar("LANG_V",$lang); if(isset($_POST["tipo_preventivo"])){ $viewForm = $_POST["tipo_preventivo"]; $title = $pageTitle[$lang][$_POST["tipo_preventivo"]]; $tmpl->addVar("form","TIPO_PREVENTIVO_N","tipo_preventivo"); $tmpl->addVar("form","TIPO_PREVENTIVO_V",$viewForm); foreach ($buttonLabels[$lang] As $blk=>$blv) $tmpl->addVar("form",strtoupper($blk),$blv); } else { $viewForm = $form["CHOOSE_ESTIMATE"]; $pt = &$pageTitle[$lang]; $title = $pt[$form["CHOOSE_ESTIMATE"]]; if(count($pt)>1){ for($i=1;$i