<?

$SHOW[pratiche][0]["object_template"]="contact.tpl";
$SHOW[pratiche][0]["sql_select"]="SELECT * FROM pratiche p WHERE %[PERM]% AND id=%[ID]%";
$SHOW[pratiche][0]["options"]="perm::1";
$SHOW[pratiche][0]["Fields"]["pr_codice"]=PRATICHE_CODE;
$SHOW[pratiche][0]["Fields"]["pr_oggetto"]=PRATICHE_SUBJ;
$SHOW[pratiche][0]["Fields"]["pr_numero"]=PRATICHE_NUMBER;
$SHOW[pratiche][0]["Fields"]["pr_tipo"]="Tipo::[SELECT * FROM INT_pratiche_tipo WHERE codice='%ID%';;ttp_desc]";
$SHOW[pratiche][0]["Fields"]["pr_data_ins"]=PRATICHE_INSERT_DATE."::date";
$SHOW[pratiche][0]["Fields"]["pr_data_mod"]=PRATICHE_LAST_UPDATE."::date";
$SHOW[pratiche][0]["Fields"]["pr_data_inizio"]=PRATICHE_START_PREST."::date";
$SHOW[pratiche][0]["Fields"]["pr_ref_idcliente"]=PRATICHE_CUSTOMER."::func=>pratiche_cliente_show";
$SHOW[pratiche][0]["Fields"]["pr_ref_idavvr"]=PRATICHE_AVVR."::func=>pratiche_avvr_show";
$SHOW[pratiche][0]["Fields"]["pr_ref_idbenefic"]=PRATICHE_BENEF."::func=>pratiche_benef_show";
$SHOW[pratiche][0]["Fields"]["pr_ref_idaltri"]=PRATICHE_OTHERS."::func=>pratiche_altri_show";
$SHOW[pratiche][0]["Fields"]["pr_operatore"]=PRATICHE_USER."::func=>pratiche_operator_show";
$SHOW[pratiche][0]["Fields"]["pr_valore"]=PRATICHE_VALUE."::func=>pratiche_format_value";
$SHOW[pratiche][0]["Fields"]["pr_fido"]=PRATICHE_FIDO;
$SHOW[pratiche][0]["Fields"]["pr_criterio"]=PRATICHE_CRIT;
$SHOW[pratiche][0]["Fields"]["pr_comp_cod"]=PRATICHE_AUT_COMP;
$SHOW[pratiche][0]["Fields"]["pr_comp_desc"]=PRATICHE_AUT_COMP_DESC;
$SHOW[pratiche][0]["Fields"]["pr_nprovv"]=PRATICHE_NPROV;
$SHOW[pratiche][0]["Fields"]["pr_nruolo"]=PRATICHE_NRUOLO;
$SHOW[pratiche][0]["Fields"]["pr_giudice"]=PRATICHE_GIUD;
$SHOW[pratiche][0]["Fields"]["pr_repertorio"]=PRATICHE_NREP;
$SHOW[pratiche][0]["Fields"]["note"]=PRATICHE_NOTE;
$SHOW[pratiche][0]["Fields"]["pr_scad"]=PRATICHE_REL_SCAD;
$SHOW[pratiche][0]["Fields"]["pr_perc_onor"]=PRATICHE_PERC_ONOR;
$SHOW[pratiche][0]["Fields"]["pr_on_orar"]=PRATICHE_HOUR_PRICE;
$SHOW[pratiche][0]["Fields"]["pr_referral"]=PRATICHE_REFERRAL;
$SHOW[pratiche][0]["Fields"]["pr_uff_orig"]=PRATICHE_UORIG."::[SELECT * FROM gruppi WHERE id='%ID%';;name]";
$SHOW[pratiche][0]["Fields"]["pr_prof_orig"]=PRATICHE_PORIG."::[SELECT * FROM users WHERE id='%ID%';;nome]";



$SHOW[pratiche][1]["object_template"]="pratiche_sitcont.tpl";
$SHOW[pratiche][1]["Fields"]["pr_codice"]=PRATICHE_CODE;
$SHOW[pratiche][1]["Fields"]["simp"]=PRATICHE_SIMP;
$SHOW[pratiche][1]["Fields"]["snimp"]=PRATICHE_SNIMP;
$SHOW[pratiche][1]["Fields"]["dir"]=PRATICHE_DIR;
$SHOW[pratiche][1]["Fields"]["onor"]=PRATICHE_ONOR;
$SHOW[pratiche][1]["Fields"]["onor_or"]=PRATICHE_ONOR_OR;
$SHOW[pratiche][1]["Fields"]["onor_ut"]=PRATICHE_ONOR_UT;
$SHOW[pratiche][1]["Fields"]["acco"]=PRATICHE_ACCO;
$SHOW[pratiche][1]["Fields"]["anti"]=PRATICHE_ANTI;
$SHOW[pratiche][1]["Fields"]["subt1"]=PRATICHE_SUBT;
$SHOW[pratiche][1]["Fields"]["subt2"]=PRATICHE_SUBT;
$SHOW[pratiche][1]["Fields"]["subt3"]=PRATICHE_SUBT;
$SHOW[pratiche][1]["Fields"]["subm"]=PRATICHE_SUBT;
$SHOW[pratiche][1]["Fields"]["subf"]=PRATICHE_TOBILL;
$SHOW[pratiche][1]["Fields"]["pr_cliente"]=PRATICHE_CUSTOMER;
$SHOW[pratiche][1]["Fields"]["pr_oggetto"]=PRATICHE_SUBJ;
$SHOW[pratiche][1]["Fields"]["pr_valore"]=PRATICHE_VALUE."::func=>pratiche_format_value";
$SHOW[pratiche][1]["Fields"]["pr_fido"]=PRATICHE_FIDO;
$SHOW[pratiche][1]["Fields"]["billem"]=PRATICHE_BILLEM;
$SHOW[pratiche][1]["Fields"]["fattem"]=PRATICHE_FATTEM;




function pratiche_operator_show($row)
{
	global $DB,$CONF;
	
	$cnt=0;
	
	foreach(explode(",,",$row[pr_operatore]) as $v)
	{
		if ($cnt > 0) $cur .= ", ";
		$rs=$DB->Execute("SELECT * FROM ".$CONF[auth_db_table]." WHERE id='".$v."'");
		$op=$rs->FetchRow();
		$cur .= $op[nome]." (".$op[codice].")";
		$cnt++;
	}
	return $cur;
}



function pratiche_avvr_show($row)
{
	global $DB,$CONF;
	
	$cnt=0;
	
	foreach(explode(",,",$row[pr_ref_idavvr]) as $v)
	{
		if ($cnt > 0) $cur .= ", ";
		$rs=$DB->Execute("SELECT * FROM contact WHERE id='".$v."'");
		$op=$rs->FetchRow();
		$cur .= '<a href="javascript: loadLayerWindow(\''.$CONF[url_base].$CONF[dir_modules].'contact/pages/pratiche_contact.php?id='.$op[id].'\');">'.$op[nome].'</a>';
		$cnt++;
	}
	return $cur;
}



function pratiche_altri_show($row)
{
	global $DB,$CONF;
	
	$cnt=0;
	
	foreach(explode(",,",$row[pr_ref_idaltri]) as $v)
	{
		if ($cnt > 0) $cur .= ", ";
		$rs=$DB->Execute("SELECT * FROM contact WHERE id='".$v."'");
		$op=$rs->FetchRow();
		$cur .= '<a href="javascript: loadLayerWindow(\''.$CONF[url_base].$CONF[dir_modules].'contact/pages/pratiche_contact.php?id='.$op[id].'\');">'.$op[nome].'</a>';
		$cnt++;
	}
	return $cur;
}


function pratiche_cliente_show($row)
{
	global $DB,$CONF;
	
	$cnt=0;
	
		$rs=$DB->Execute("SELECT * FROM contact WHERE id='".$row[pr_ref_idcliente]."'");
		$op=$rs->FetchRow();
		$cur .= '<a  href="javascript: loadLayerWindow(\''.$CONF[url_base].$CONF[dir_modules].'contact/pages/pratiche_contact.php?id='.$op[id].'\');">'.$op[nome].'</a>';
	return $cur;
}


function pratiche_benef_show($row)
{
	global $DB,$CONF;
	
	$cnt=0;
	
	foreach(explode(",,",$row[pr_ref_idbenefic]) as $v)
	{
		if ($cnt > 0) $cur .= ", ";
		$rs=$DB->Execute("SELECT * FROM contact WHERE id='".$v."'");
		$op=$rs->FetchRow();
		$cur .= '<a href="javascript: loadLayerWindow(\''.$CONF[url_base].$CONF[dir_modules].'contact/pages/pratiche_contact.php?id='.$op[id].'\');">'.$op[nome].'</a>';
		$cnt++;
	}
	return $cur;
}

function pratiche_format_value($row)
{
	if ($row[pr_valore]=="-1") return PRATICHE_VAL_IND;
	if ($row[pr_valore]=="-2") return PRATICHE_VAL_INDEXT;
	return $row[pr_valore];
}
?>