#! /bin/bash
#------------------------------------------------------------------------------
#see licence at the end
ThisScriptVersion="1.16 - 22 02 2022 rev 1 deprecated source"
GoeVersion="$ThisScriptVersion Last Update : `stat -c %z $0 | cut -d"." -f1`"
Date=`date +%A_%x-%H:%M:%S`
CurrentUser=`whoami`
AllParameters="$*"
UserLogins=""
#------------------------------------------------------------------------------
##StartConfig
#------------------------------------------------------------------------------
# This part of the file is copied to /usr/local/etc/goe/goe.conf
# Edit the default configuration in /usr/local/etc/goe/goe.local.conf to keep modifications
# panel mode is set /usr/local/etc/goe/goe.mode.conf, check goe --mode command
#

#Site parameters
#---------------
HttpUser="www-data"
TopImage="images/background.gif"
TopLogo="images/top_background.jpg"
TapeImage="images/tape.png"
DiskImage="images/disk.png"
ServiceImage="images/disk.png"
SiteCss="goe.css"
SiteRefreshResult="12"
SiteRefreshPeriod="8"
SiteUrl="."
SiteAbout="http://sisalp.fr/index.php/post/Hebergement-OpenERP-et-Tryton-par-SISalp-Le-panneau-d-administration-du-serveur-VDS"
SiteSupport="https://sisalp.fr/index.php/category/A-propos-de-SISalp"
InputStyle="style=\\\"cursor:pointer; width:300px; padding:3px 20px; margin: 3px; background-color: #eeeeee; border:solid 1px #999999;\\\""

#goe background tasks parameters
#-------------------------------
XoeAuthorizedUser="sisalpuser"
XoeDir="/home/$XoeAuthorizedUser"
GoeDir="/home/$XoeAuthorizedUser/goe.panel"
GoeConfDir="/usr/local/etc/goe"
GoeConf="$GoeConfDir/goe.conf"
GoeLocalConf="$GoeConfDir/goe.local.conf"
GoeLoginConf="$GoeConfDir/goe.login.conf"
GoeModeConf="$GoeConfDir/goe.mode.conf"
Drawings="$GoeDir/draw"
Templates="$GoeDir/template"
Actions="$GoeDir/action"
GoeData="$GoeDir/data"
GoeActivity="$GoeDir/goe.activity"
GoeUploads="$GoeDir/uploads"
GoeTranslations="en fr"
GoeTranslationFile="$GoeConfDir/goe.translation"
GoeCustomTranslationFile="$GoeConfDir/goe.custom.translation"
GoeCurrentLanguage="$GoeConfDir/goe.language.conf"
GoeBuzyFlag="$GoeActivity/buzy.flag"
GoeActingFlag="$GoeActivity/acting"
PageLog="$GoeDir/goe.page.log"
PageHistory="100"
GoeLog="/dev/null"
GoeLogFile="$GoeDir/goe.log"
GoeActionsLog="$GoeDir/goe.actions.log"
DrawingsLog="$GoeDir/goe.drawings.log"
GoeDataLog="$GoeDir/goe.data.log"
SiteRefreshPeriodFile="$GoeDir/goe.refresh_period.conf"
SiteRefreshModeFile="$GoeDir/goe.refresh_mode.conf"
XoeLog="/home/$XoeAuthorizedUser/xoe.logs/server.$XoeAuthorizedUser.log"
XoeServicesData="$GoeDir/goe.service_data"
ActivityFile="$GoeActivity/goe.activity"
GoePidFile="$GoeDir/goe.background.pid"
SiteScriptName="index.php"
SiteImages="images"
ImageSource="http://download.sisalp.net/scripts/panel/images/"
GoeDownloadSource="http://download.sisalp.net/scripts/panel/goe"
PanelDownloadSource="http://download.sisalp.net/scripts/panel/panel.panel"
CssDownloadSource="http://download.sisalp.net/scripts/panel/goe.css"
MoocDownloadSource="http://download.sisalp.net/scripts/panel/mooc"
LoopStatus="$GoeDir/goe.loop.status"
#BackgroundMode Auto | Manual
#RefreshMode All | Displayed
RefreshMode="Displayed"
xTimes="5"
Pace="12"
LogTailLength="20"
LogDetailLength="500"
GeneralLogTailLength="60"
GeneralLogDetailLength="500"
MaxPhpUploadSize="50M"
MaxArchiveUploadSize="20971520"

##LocalConfig
#----------------
# This part of the configuration file is also copied to /usr/local/etc/goe/goe.local.conf
# panel mode is set in /usr/local/etc/goe/goe.mode.conf, check goe --mode command
# mode parameters per default
#set_mode	demo|business|education
ServerMode="demo"
#dashboard list Available :  help support options admin_guide contract openservice closeservice monitor mooc services log
ServerMenuEnabled="help support options admin_guide contract monitor mooc services log"
#show|hide
ServerMenuMode="hide"
AdminGuideMode="hide"
ServerContractMode="hide"
OpenServiceMode="hide"
CloseServiceMode="hide"
SystemInfoMode="hide"
MoocInfoMode="hide"
ServiceDetailsMode="hide"
ServerLogMode="hide"

#default button lists
ServiceButtonsFullList="editservicemenu renew start stop restart newcase company drop newmooc managemooc exam upload installarchive upgrade"
# downgrade"
DatabaseButtonsFullList="editdatabasemenu save restore clone copy reference delete wipe_out dbupdate"

ServiceButtonsDefaultList="editservicemenu start stop restart newcase company drop newmooc managemooc exam upload installarchive upgrade"
DatabaseButtonsDefaultList="editdatabasemenu save restore clone copy reference delete wipe_out dbupdate"
RestrictedButtonsList="editservicemenu start stop restart - editdatabasemenu save restore"
CustomPageHeaderConf="$GoeConfDir/goe.custom_page_header.conf"
CustomPageFooterConf="$GoeConfDir/goe.custom_page_footer.conf"


#------------------------------------------------------------------------------
##EndConfig
#------------------------------------------------------------------------------
# Gestion des traductions
#------------------------------------------------------------------------------
#TR T_SiteTitle	Administration panel of your ERP server by SISalp : Panneau d administration de votre serveur ERP par SISalp
#TR T_SiteNameEnterprise	Tryton, Odoo and OpenERP on line : Tryton, Odoo et OpenERP en ligne
#TR T_SiteNameAcademy	ERP Academy : Academie ERP
#TR T_SiteSloganEnterprise	Virtual Dedicated Server<br/>by SISalp : Serveur Virtuel Dedie<br/>par SISalp
#TR T_SiteSloganAcademy	Training center for<br/>technical classes in enterprise management : Cas pedagogiques d apprentissage<br/>des techniques avancees de gestion


if [ ! -d $GoeDir ] ; then mkdir $GoeDir ; fi
if [ ! -d $GoeConfDir ] ; then mkdir $GoeConfDir ; fi
if [ -f "$GoeConf" ] ; then . $GoeConf ; fi
if [ -f "$GoeLocalConf" ] ; then . $GoeLocalConf ; fi
if [ -f "$GoeLoginConf" ] ; then . $GoeLoginConf ; fi
if [ -f "$GoeModeConf" ] ; then . $GoeModeConf ; fi

# for xoe evolution xoe main dir changed and goe conf update is complex
#Analyse des parametres d appel
case "$1" in
--*)
	LoginUser="guest"
	;;
*)
	LoginUser="$1"
	shift
	;;
esac
case "$1" in
--*)
	if [ -f $GoeCurrentLanguage ] ; then
		Language=`cat $GoeCurrentLanguage`
	else
		Language="en"
	fi
	;;
*)
	Language="$1"
	echo "$Language" > $GoeCurrentLanguage 
	shift
	;;
esac
#------------------------------------------------------------------------------
Option="$1"
case "$Option" in
--*)
	;;
*)
	Option="--$Option"
	;;
esac
shift
OptionParameters="$*"
ZoneName="$1"
NewMode="$1"
Service="$1"
NumberTimes="$1"
UserName="$1"
CodeAltSource="$*"
SetAuthorizedUser="$1"
SearchString="$*"
ShellCommand="$*"
BlablaVersion="$1"
DashboardOption="$1"
shift
Drawing="$1"
Database="$1"
CommentDatabase=`echo "$Database" | sed s/--/-/g`
Period="$1"
UserPassword="$1"
DashboardValue="$1"
DashboardNewService="$1"
DashboardList="$*"
shift
Action="$1"
UserRole="$*"
shift
ActionParameters="$*"

#------------------------------------------------------------------------------
LOG_MESSAGE ()
#------------------------------------------------------------------------------
{
#$1 line_number $2 code : 404|500|501|502|-[e][g][x] $3 exit|message
case "$2" in
404)
	Message="404 $HOSTNAME|goe|`date +%A_%x-%H:%M:%S:%3N`|WARNING|$CurrentUser|$$|$1|$Option WARNING : Cannot find page $Drawing. goe $AllParameters --- $*"
	echo "$Message" >> $GoeLog
	#echo "$Message" >> $XoeLog
	#echo "$Message"
	;;
500)
	Message="500 $HOSTNAME|goe|`date +%A_%x-%H:%M:%S:%3N`|ERROR|$CurrentUser|$$|$1|$Option ERROR : Cannot execute action $Action. goe $AllParameters --- $*"
	echo "$Message" >> $GoeLog
	echo "$Message" >> $XoeLog
	#echo "$Message"
	;;
501)
	Message="501 $HOSTNAME|goe|`date +%A_%x-%H:%M:%S:%3N`|WARNING|$CurrentUser|$$|$1|$Option WARNING : System freeze or overloaded goe $AllParameters --- $*"
	echo "$Message" >> $GoeLog
	#echo "$Message" >> $XoeLog
	#echo "$Message"
	;;
502)
	Message="502 $HOSTNAME|goe|`date +%A_%x-%H:%M:%S:%3N`|ERROR|$CurrentUser|$$|$1|$Option ERROR : Access denied to internal resource goe $AllParameters --- $*"
	echo "$Message" >> $GoeLog
	echo "$Message" >> $XoeLog
	#echo "$Message"
	;;
*)
	Message="$HOSTNAME|goe|`date +%A_%x-%H:%M:%S:%3N`|INFO |$CurrentUser|$$||$Option	$*"
	;;
esac
case "$2" in
*e*)
	echo "$Message"
	;;
esac
#case "$2" in
#*g*)
echo "$Message" >> $GoeLog
#	;;
#esac
case "$2" in
*x*)
echo "$Message" >> $XoeLog
	;;
esac

case "$3" in
exit)
	exit $2
	;;
esac
}
#end 
#------------------------------------------------------------------------------
WAIT_FOR ()
#------------------------------------------------------------------------------
{
#exemple  WAIT_FOR $LINENO 10 ! -f /tmp/toto  #delay in O.01 s
wf_call="$1"
shift
ttle="$1" #in  s
shift
iwf=0
#for ((i=0;i<$ttle;i=i+1)) ; do
#	if [ $* ] ; then
#		break
#	fi
#	sleep 0.01
#done
if [ $* ] ; then
	echo -n "." > /dev/null
#$GoeBuzyFlag.log
else
	echo -n "!$wf_call-$ttle-$*!" >> $GoeBuzyFlag.log
	for ((iwf=0;iwf<$ttle;iwf=iwf+1)) ; do	sleep 0.01 ; done
fi
#if [ $i -ge $ttle ] ; then
#	echo "$LINENO|$$|$wf_call|WAITFOR|`whoami`| goe was BUZY on `date +%A_%x-%H:%M:%S:%3N` `whoami` WAITFOR $Option too long time ${ttle}0ms waiting condition $*" >> $GoeBuzyFlag.log
#	LOG_MESSAGE "$LINENO 501 exit $cb_call|WAITFOR| too long time ${ttle}0ms waiting condition $*"
#else echo "goe did not wait on `date +%A_%x-%H:%M:%S:%3N` $cb_call|WAIT FOR too long time ${ttle}0ms waiting condition $*" >> $GoeBuzyFlag.log
#fi
}
#end 
#------------------------------------------------------------------------------
CHECK_BUZY ()
#------------------------------------------------------------------------------
{
#il faudrait un vrai semaphore
cb_call="$1"
shift
case "$1" in
set)
	echo "$LINENO|$$|$cb_call|CHECK_BUZY|`whoami`|set I am buzy from now on `date +%A_%x-%H:%M:%S:%3N`" > $GoeBuzyFlag
	echo -n "s"  >> $GoeBuzyFlag.log
	#echo "$LINENO|$$|$cb_call|CHECK_BUZY|`whoami`|set I am buzy from now on `date +%A_%x-%H:%M:%S:%3N`"  >> $GoeBuzyFlag.log
	;;
release)
	
	rm -f $GoeBuzyFlag
	echo -n "r"  >> $GoeBuzyFlag.log
	#echo "$LINENO|$$|$cb_call|CHECK_BUZY|`whoami`|release I am free from now on `date +%A_%x-%H:%M:%S:%3N`" >> $GoeBuzyFlag.log
	;;
*)
	if [ -e $GoeBuzyFlag ] ; then
		echo -n "w"  >> $GoeBuzyFlag.log
		#echo "$LINENO|$$|$cb_call|CHECK_BUZY|`whoami`|check and wait I have to WAIT because goe is buzy on `date +%A_%x-%H:%M:%S:%3N`" >> $GoeBuzyFlag.log
		#WAIT_FOR $LINENO 200 ! -e $GoeBuzyFlag
		sleep 1
		echo -n "m"  >> $GoeBuzyFlag.log
	fi
	#chmod 660 $GoeBuzyFlag.log > /dev/null 2>&1
	;;
esac
}
#end 

#------------------------------------------------------------------------------
CAT ()
#------------------------------------------------------------------------------
{
WAIT_FOR $LINENO 200 -f $1
cat $1
}
#end 
#------------------------------------------------------------------------------
GET_XOE_DEFAULTS ()
#------------------------------------------------------------------------------
{
ServiceNumber="0"
ServiceList="defaulted_value_$LINENO"
LoginUser="defaulted_value_$LINENO"
LoginPassword="defaulted_value_$LINENO"
LoginRole="defaulted_value_$LINENO"
ServiceMode="defaulted_value_$LINENO"
TestRunning="defaulted_value_$LINENO"
PgService="defaulted_value_$LINENO"
ServiceErpName="defaulted_value_$LINENO"
ServiceVersion="defaulted_value_$LINENO"
ServiceRole="defaulted_value_$LINENO"
ServiceLanguage="defaulted_value_$LINENO"
Available_Buttons="defaulted_value_$LINENO"
Enabled_Buttons="defaulted_value_$LINENO"
ServiceUrl="defaulted_value_$LINENO"
ServiceCompatibilityList="defaulted_value_$LINENO"
ServiceDocumentation="defaulted_value_$LINENO"
ServiceLast="defaulted_value_$LINENO"
ServiceLastDay="defaulted_value_$LINENO"
ServiceSituation="defaulted_value_$LINENO"
ServicePeriod="defaulted_value_$LINENO"
ServiceGrace="defaulted_value_$LINENO"
ServiceAsleep="defaulted_value_$LINENO"
ServiceType="defaulted_value_$LINENO"
ServiceDate="defaulted_value_$LINENO"
}
#end 
#------------------------------------------------------------------------------
GET_XOE_DATA ()
#------------------------------------------------------------------------------
{
get_xoe_data_key="$1"
get_xoe_data_value="$2"
if [ ! -f $XoeServicesData ] ; then
	$0 --get_service_list
fi
GET_XOE_DEFAULTS
if [ -f $XoeServicesData ] ; then
	if [ -z "$get_xoe_data_key" ] ; then
		. $XoeServicesData
	else
		if [ -z "$get_xoe_data_value" ] ; then
			cat $XoeServicesData | grep "^#Service:$get_xoe_data_key:" | cut -f2- > /tmp/goe.get_xoe_data.$$.sh
		else
			cat $XoeServicesData | grep "^#Service:$get_xoe_data_key:" | cut -f2- | grep "^$get_xoe_data_value=" > /tmp/goe.get_xoe_data.$$.sh
		fi
		. /tmp/goe.get_xoe_data.$$.sh
		rm -f /tmp/goe.get_xoe_data.$$.sh
	fi
fi
}
#end 
#------------------------------------------------------------------------------
GET_ROLE ()
#------------------------------------------------------------------------------
{
LoginRole=`echo "$UserLogins" 2>/dev/null | grep -m 1 "^$LoginUser "  | cut -d" " -f3`
if [ -z "$LoginRole" ] && [ -f "$XoeServicesData" ] ; then
	GET_XOE_DATA $LoginUser
fi
}
#end 
#-------------------------------------------------------------------------
NEW_PASSWORD ()
#-------------------------------------------------------------------------
{
case "$1" in
-min)
	pw_letters=(a b c d e f g h i j k m n o p q r s t u v w x y z a b c d e f g h i j k m n o p q r s t u v w x z 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 )
	shift
	;;
-letters)
	pw_letters=(a b c d e f g h i j k m n o p q r s t u v w x y z )
	shift
	;;
*)
	pw_letters=(a b c d e f g h i j k m n o p q r s t u v w x y z A B C D E F G H I J K L M N P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 )
	;;
esac

if [ -z "$1" ] ; then
	pw_nb_digits=12
else
	pw_nb_digits="$*"
fi
pw_range="${#pw_letters[*]}"
NEW_PWD=""
for nb_digit in $pw_nb_digits ; do
	if [ ! -z "$NEW_PWD" ] ; then NEW_PWD="${NEW_PWD}""_" ; fi
	for ((  pw_digit = 1 ;  pw_digit <= $nb_digit ;  pw_digit++  )) ; do
		pw_index="$(($RANDOM%$pw_range))"
		NEW_PWD="${NEW_PWD}""${pw_letters[$pw_index]}"
	done
done
echo "$NEW_PWD"
}
#end 
#------------------------------------------------------------------------------
GET_DATA ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g GET_DATA $* Mode $ServerMode command $Option $AllParameters
#SECURITE il conviendrait d'initialiser les variables avant de jouer le fichier d'affectations
data_type="$1"
case "$data_type" in
-page)
	LOG_MESSAGE $LINENO -g Chargement de la liste des services GET_DATA $* Mode $ServerMode command $Option $AllParameters
	WAIT_FOR $LINENO 190 -f "$GoeData/ServiceList.data"
	. $GoeData/ServiceList.data
	;;
-contract)
	#LOG_MESSAGE $LINENO -g Chargement des informations de gestion du contrat
	WAIT_FOR $LINENO 200 -f "$GoeData/contract.data"
	. $GoeData/contract.data
	;;
-admin_guide)
	#LOG_MESSAGE $LINENO -g Chargement des informations d admin du serveur
	WAIT_FOR $LINENO 200 -f "$GoeData/admin_guide.data"
	. $GoeData/admin_guide.data
	;;
-openservice)
	#LOG_MESSAGE $LINENO -g Chargement des informations ouverture de service
	WAIT_FOR $LINENO 200 -f "$GoeData/openservice.data"
	. $GoeData/openservice.data
	;;
-closeservice)
	#LOG_MESSAGE $LINENO -g Chargement des informations cloture de service
	WAIT_FOR $LINENO 200 -f "$GoeData/closeservice.data"
	. $GoeData/closeservice.data
	;;
-system)
	#LOG_MESSAGE $LINENO -g Chargement des informations relatives au systeme
	WAIT_FOR $LINENO 200 -f "$GoeData/system.data"
	. $GoeData/system.data
	;;
-mooc)
	#LOG_MESSAGE $LINENO -g Chargement des informations relatives aux mooc
	WAIT_FOR $LINENO 120 -f "$GoeData/mooc.data"
	. $GoeData/mooc.data
	;;
-service)
	#LOG_MESSAGE $LINENO -g Chargement des donnees du service $Service
	WAIT_FOR $LINENO 130 -f $GoeData/$Service.service.data
	. $GoeData/$Service.service.data
	LANGUAGE $LINENO $ServiceLanguage
	;;
-summary)
	#LOG_MESSAGE $LINENO -g Chargement des donnees essentielles du service $Service
	WAIT_FOR $LINENO 130 -f $GoeData/$Service.dashboard.data
	. $GoeData/$Service.dashboard.data
	;;
-database)
	#LOG_MESSAGE $LINENO -g Chargement des donnees de la base $Database du service $Service
	WAIT_FOR $LINENO 140 -f $GoeData/$Service.$Database.database.data
	. $GoeData/$Service.$Database.database.data	
	;;
-general_log)
	#LOG_MESSAGE $LINENO -g Chargement des donnees du log general
	WAIT_FOR $LINENO 160 -f $GoeData/general_log.data
	. $GoeData/general_log.data
	;;
esac
}
#end 
#------------------------------------------------------------------------------
ZONE_TO_SERVICE ()
#------------------------------------------------------------------------------
{
LOG_MESSAGE $LINENO -g  ZONE_TO_SERVICE $* zone $ZoneName
if [ ! -z "$1" ] ; then
	TemplateFile="$1"
	case `echo "$TemplateFile" | cut -d. -f2` in
	template)
		case "$ZoneName" in
		zone.log*|zone.page*)
			Service=""
			Database=""
			;;
		zone*)
			Service=`echo "$ZoneName" | cut -d. -f2`
			GET_DATA -service
			if [ ! -z `echo "$ZoneName" | cut -d. -f4` ] ; then
				Database=`echo "$ZoneName" | cut -d. -f3`
				GET_DATA -database
			else
				Database=""
			fi
			LANGUAGE $LINENO $Language
			;;
		esac
		;;
	*)
		Service=`echo "$TemplateFile" | cut -d. -f1`
		GET_DATA -service
		TemplateFile=`echo "$TemplateFile" | cut -d. -f2-`
		case `echo "$TemplateFile" | cut -d. -f2` in
		template)
			Database=""
			;;
		*)
			Database=`echo "$TemplateFile" | cut -d. -f1`
			GET_DATA -database
			TemplateFile=`echo "$TemplateFile" | cut -d. -f2-`
			;;
		esac
		LANGUAGE $LINENO $Language
		;;
	esac
else
	case "$ZoneName" in
	zone.log*|zone.page*)
		Service=""
		Database=""
		;;
	zone*)
		Service=`echo "$ZoneName" | cut -d. -f2`
		GET_DATA -service
		if [ ! -z `echo "$ZoneName" | cut -d. -f4` ] ; then
			Database=`echo "$ZoneName" | cut -d. -f3`
			GET_DATA -database
		else
			Database=""
		fi
		LANGUAGE $LINENO $Language
		;;
	esac
fi
CommentDatabase=`echo "$Database" | sed s/--/-/g`
LOG_MESSAGE $LINENO -g  ZONE_TO_SERVICE service $Service database $Database templatefile $TemplateFile
}
#end 
#------------------------------------------------------------------------------
DRAWING_TO_SERVICE ()
#------------------------------------------------------------------------------
{
LOG_MESSAGE $LINENO -g  DRAWING_TO_SERVICE $* drawing_name $1
Service=""
Database=""
if [ ! -z "$1" ] ; then
	drawingname="$1"
	case "$drawingname" in
	page.draw|log_detail.draw)
		;;
	*.log_detail.draw)
		Service=`basename $drawingname .log_detail.draw`
		;;
	*.detail.draw)
		information=`basename $drawingname .detail.draw`
		case "$information" in
		*.*)
			Service=`echo "$information" | cut -d. -f1`
			Database=`echo "$information" | cut -d. -f2`
			CommentDatabase=`echo "$Database" | sed s/--/-/g`
			;;
		*)
			Service="$information"
			;;
		esac
		;;
	*.draw)
		Service=`basename $drawingname .draw`
		;;
	esac
fi
LOG_MESSAGE $LINENO -g  DRAWING_TO_SERVICE service $Service database $Database drawing_name $drawingname
}
#end 
#------------------------------------------------------------------------------
DRAW ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g  DRAW $*
DrawingName="$1"
if [ -z "$DrawingName" ] ; then
	DrawingName="page.draw"
fi
if [ ! -e $PageLog ] || [ -w $PageLog ] ; then
	echo "$DrawingName" >> $PageLog
	recentpages=`tail -n $PageHistory $PageLog`
	echo "$recentpages" > $PageLog
fi
#echo "DRAW write in $PageLog `date +'%Hh%Mm%Ss:%3N'` $$ $CurrentUser $Option $DrawingName"  >> $GoeDir/goe.draw.log
case "$DrawingName" in
*.draw)
	case "$DrawingName" in
	page*)
		#LOG_MESSAGE $LINENO -g  DRAW Controle des droits sur page.draw
		case "$LoginRole" in
		Admin*|admin*)
			;;
		*)
			LOG_MESSAGE $LINENO -g  DRAW Substitution de la page par $LoginRole.draw
			DrawingName="$LoginRole.draw"
			;;
		esac
		;;
	*)
		#LOG_MESSAGE $LINENO -g  DRAW Controle des droits sur les autres pages
		case "$LoginRole" in
		Admin*|admin*)
			;;
		*)
			#LOG_MESSAGE $LINENO -g  DRAW Controle des droits d acces a la page
			case "$DrawingName" in
			*/*|*..*|*'#'*|*'$'*|*'&'*|*';'*|*.draw*.draw)
				# Hacking attempt
				LOG_MESSAGE $LINENO -g  DRAW Tentative de violation de securite par $LoginRole sur la page $DrawingName
				DrawingName="Access_Denied"
				;;
			$LoginRole.*)
				# Authorized
				;;
			*)
				LOG_MESSAGE $LINENO -g  DRAW Refus de l acces demande par $LoginRole a la page $DrawingName
				DrawingName="Access_Denied"
				;;
			esac
			;;
		esac
		;;
	esac
	if [ -z "$LoginRole" ] ; then
		#LOG_MESSAGE $LINENO -g  DRAW refus des demandes sans identifiant utilisateur
		DrawingName="Access_Denied"
	fi
	CHECK_BUZY $LINENO
	WAIT_FOR $LINENO 150 -f "$Drawings/$DrawingName"
	if [ -f "$Drawings/$DrawingName" ] ; then
		cat $Drawings/$DrawingName
	else
		# if not available, content is created on the fly
		if [ -z "$ZoneName" ] ; then
			ZoneName="$DrawingName"
		fi
		LOG_MESSAGE $LINENO -g "Looking for missing page $Drawings/$DrawingName, served in real time by $CurrentUser /usr/local/bin/goe --draw_now $ZoneName $DrawingName"
		case "$CurrentUser" in
		$XoeAuthorizedUser)
			/usr/local/bin/goe --draw_now $ZoneName $DrawingName
			;;
		$HttpUser)
			#sudo su $XoeAuthorizedUser -c "/usr/local/bin/goe --draw_now $ZoneName $DrawingName"
			/usr/local/bin/goe --draw_now $ZoneName $DrawingName
			;;
		root)
			su $XoeAuthorizedUser -c "/usr/local/bin/goe --draw_now $ZoneName $DrawingName"
			;;
		esac
	fi
	;;
*.template)
	TemplateFile="$DrawingName"
	ZONE_TO_SERVICE $TemplateFile
	CHECK_BUZY $LINENO
	WAIT_FOR $LINENO 100 -f $Templates/$TemplateFile
	if [ -f "$Templates/$TemplateFile" ] ; then
		. $Templates/$TemplateFile
	else
		if [ -f $Drawings/default.detail.draw ] ; then
			LOG_MESSAGE $LINENO -g "looking for template $Templates/$TemplateFile,  served $Drawings/default.detail.draw instead"
			cat $Drawings/default.detail.draw
		else
			LOG_MESSAGE $LINENO 404 exit "looking for $Templates/$TemplateFile"
		fi
	fi
	;;
dashboard)
	#goe --page
	#TR T_Toggle	Modification of dashboard display : Modification de l'affichage du tableau de bord
	#TR T_Toggle_return_message	New dashboard format is going to be displayed : Le nouveau format du tableau de bord va etre affiche
	echo "<zone name=\"zone.toggle_result\">
        <zone_refresh><![CDATA[<meta http-equiv=\"Refresh\" content=\"2;url=../index.php\" />]]></zone_refresh>
        <zone_title><![CDATA[<title>$T_Toggle</title>]]></zone_title>
        <zone_type>button_result</zone_type>
        <zone_status>ok</zone_status>
	<zone_html><![CDATA[ <a href=\"$SiteUrl\"><img src=\"images/back.png\" alt=\"$T_Page_back\" title=\"$T_Page_back\" /></a><hr/><br/>$T_Toggle<br/>$T_Toggle_return_message <br/> ]]></zone_html>
</zone>"

	;;
*)
	LOG_MESSAGE $LINENO 404 exit
	;;
esac
}
#end 
#------------------------------------------------------------------------------
RUN_ACTION ()
#------------------------------------------------------------------------------
{
TemplateFile="$1"
if [ ! -z "$ActionParameters" ] ; then
	case "$TemplateFile" in
	goe)
		$0 $ActionParameters
		;;
	*)
		case "$TemplateFile" in
		*.template)
			ZONE_TO_SERVICE $TemplateFile
			;;
		esac
		WAIT_FOR $LINENO 100 -x "$Actions/$TemplateFile"
		if [ -x "$Actions/$TemplateFile" ] ; then
			ActionMessage=`$Actions/$TemplateFile --check $ServerMode $ActionParameters`
			case "$ActionMessage" in
			4*|5*)
				ActionResultStatus="fault"
				;;
			*)
				ActionResultStatus="ok"
				CHECK_BUZY $LINENO
				nohup $Actions/$TemplateFile --execute $ServerMode $ActionParameters >> $GoeLog 2>&1 &
				;;
			esac
			LOG_MESSAGE $LINENO -g  Launching action $Actions/$TemplateFile $ActionParameters :: $ActionMessage
		else
			LOG_MESSAGE $LINENO 500 exit "looking for $Actions/$TemplateFile : not found or cannot execute"
		fi
		;;
	esac
else
	LOG_MESSAGE $LINENO -g RUN_ACTION No action parameters found
	ActionResultStatus="ok"
fi
}
#end
#------------------------------------------------------------------------------
TR ()
#------------------------------------------------------------------------------
{
	shift
	if [ ! -z $1 ] ; then
		translator="$1"
		shift
		lang_index="1"
		for tr_lang in $GoeTranslations ; do
			lang_text=`echo "$*" | cut -d: -f$lang_index | sed s/' $'//`
			echo "$translator=\"$lang_text\"" >> $GoeTranslationFile.$tr_lang
			lang_index=$[$lang_index +1]
		done
	fi
}
#end
#------------------------------------------------------------------------------
TRANSLATE ()
#------------------------------------------------------------------------------
{
	new_translation="no"
	for lang in $GoeTranslations ; do
		if [ ! -f $GoeTranslationFile.$lang ] ; then
			rm -f $GoeTranslationFile.*
			new_translation="yes"
			break
		fi
	done
	case "$new_translation" in
	yes)
		old_IFS=$IFS
		IFS=$'\n'
		for TR_line in `cat $0 | grep "#TR " | grep -v "#Not me"` ; do  #Not me
			IFS=$old_IFS
			TR $TR_line
			IFS=$'\n'
		done
		IFS=$old_IFS
		for lang in $GoeTranslations ; do
			echo "#" >> $GoeTranslationFile.$lang
			chmod 777 $GoeTranslationFile.$lang
			sudo chown $XoeAuthorizedUser:$HttpUser $GoeTranslationFile.$lang
		done
		;;
	esac
}
#end
#------------------------------------------------------------------------------
CHECK_ACCESS_RIGHTS ()
#------------------------------------------------------------------------------
{
case "$CurrentUser" in
$HttpUser)
	Sudo="/usr/bin/sudo"
	#sudo su $XoeAuthorizedUser -c "$0 $AllParameters"
	#exit 0
	;;
esac
case "$CurrentUser" in
root)
	Sudo=""
	for directory in $GoeDir $Drawings $Templates $Actions $GoeActivity $GoeData $GoeUploads ; do
		if [ -f $directory ] ; then
			rm $directory
		fi
		if [ ! -d $directory ] ; then
			mkdir $directory
		fi
	done
	chmod -R 770 $GoeDir > /dev/null 2>&1
	chown -R $XoeAuthorizedUser:$HttpUser $GoeDir > /dev/null 2>&1
	if [ ! -d "$GoeConfDir" ] ; then 
		mkdir $GoeConfDir ;
	fi
	if [ ! -f $GoeLoginConf ] ; then
		echo "UserLogins=\"$UserLogins\"" > $GoeLoginConf
	fi
	chmod -R 770 $GoeConfDir > /dev/null 2>&1
	chown -R $XoeAuthorizedUser:$HttpUser $GoeConfDir > /dev/null 2>&1
	TRANSLATE
	if [ -d $GoeConfDir ] ; then
		echo "$Language" > $GoeCurrentLanguage
		chmod 777 $GoeCurrentLanguage
		sudo chown $XoeAuthorizedUser:$HttpUser $GoeCurrentLanguage
	fi
	;;
$XoeAuthorizedUser)
	Sudo="/usr/bin/sudo"
	for directory in $GoeDir $Drawings $Templates $Actions $GoeActivity $GoeData $GoeUploads ; do
		if [ -f $directory ] ; then
			rm $directory
		fi
		if [ ! -d $directory ] ; then
			mkdir $directory
		fi
	done
	chmod -R 770 $GoeDir > /dev/null 2>&1
	sudo chown -R $XoeAuthorizedUser:$HttpUser $GoeDir > /dev/null 2>&1
	if [ ! -f "$ActivityFile" ] ; then
		echo -n "123456789012345" > $ActivityFile
	fi
	sudo chmod 660 $ActivityFile > /dev/null 2>&1
	sudo chown $XoeAuthorizedUser:$HttpUser $ActivityFile > /dev/null 2>&1
	if [ ! -f "$GoeBuzyFlag.log" ] ; then
		echo "List of real time conflicts" > $GoeBuzyFlag.log
		chmod 660 $GoeBuzyFlag.log > /dev/null 2>&1
		#chgrp $HttpUser $GoeBuzyFlag.log > /dev/null 2>&1
	else
		sudo chmod 660 $GoeBuzyFlag.log > /dev/null 2>&1
		#sudo chgrp $HttpUser $GoeBuzyFlag.log > /dev/null 2>&1
	fi
	if [ ! -f "$GoeLogFile" ] ; then
		echo "Initializing Goe log in $GoeLogFile" > $GoeLogFile
		chmod 666 $GoeLogFile > /dev/null 2>&1
		#chgrp $HttpUser $GoeLogFile > /dev/null 2>&1
	else
		sudo chmod 660 $GoeLogFile > /dev/null 2>&1
		#sudo chgrp $HttpUser $GoeLogFile > /dev/null 2>&1	
	fi
	if [ -f "$XoeLog" ] ; then
		sudo chmod 666 $XoeLog > /dev/null 2>&1
	fi
	TRANSLATE
	if [ -d $GoeConfDir ] ; then
		echo "$Language" > $GoeCurrentLanguage
		chmod 777 $GoeCurrentLanguage
		sudo chown $XoeAuthorizedUser:$HttpUser $GoeCurrentLanguage
	fi
	;;
*)
	Sudo="/usr/bin/sudo"
	if [ ! -w "$ActivityFile" ] ; then
		LOG_MESSAGE $LINENO 502 Cannot notify activity in $ActivityFile
	fi
	;;
esac
}
#end
#------------------------------------------------------------------------------
CHECK_ACCESS_RIGHTS
#-------------------------------------------------------------------------
PHP_UPLOAD_MAX ()
#-------------------------------------------------------------------------
{
#should check only 1 php7 version is available
	if [ -f /etc/php/7.*/apache2/php.ini ] ; then
		php_config_ini=`ls /etc/php/7.*/apache2/php.ini 2>/dev/null`
		if [ -f $php_config_ini ] && ! cat $php_config_ini | grep "^upload_max_filesize =" > /dev/null 2>&1 ; then
			echo "upload_max_filesize = $MaxPhpUploadSize" >> $php_config_ini
			echo "upload_max_filesize = $MaxPhpUploadSize is set in $php_config_ini"
		fi
	fi
}
#end 
#------------------------------------------------------------------------------
LANGUAGE ()
{
	lang_line="$1"
	shift
	new_lang="$1"
	#case "$CurrentLanguage" in
	#None)
	#	LOG_MESSAGE $LINENO -g $Option $lang_line LANGUAGE page language is set to $new_lang
	#	;;
	#esac
	if [ -z "$new_lang" ] ; then
		new_lang="en"
	fi
	case "$new_lang" in
	$CurrentLanguage)
	#	LOG_MESSAGE $LINENO -g $Option $lang_line LANGUAGE language is unchanged $Service
		;;
	*)
		. $GoeTranslationFile.$new_lang
		if [ -e $GoeCustomTranslationFile.$new_lang ] ; then
			. $GoeCustomTranslationFile.$new_lang
		fi
		CurrentLanguage="$new_lang"
	#	LOG_MESSAGE $LINENO -g $Option $lang_line LANGUAGE traduction en $CurrentLanguage $Service
		;;
	esac	
}
CurrentLanguage="None"
LANGUAGE $LINENO $Language
#------------------------------------------------------------------------------
#LOG_MESSAGE $LINENO -g ==== $0 $AllParameters

GET_ROLE
case "$Option" in
#------------------------------------------------------------------------------
--on_duty)
	echo -n "x" > $ActivityFile
	echo "<!--frontend activity is set in  $ActivityFile -->"
	LOG_MESSAGE $LINENO -g --on_duty frontend activity is set in  $ActivityFile
	exit 0
	;;
#------------------------------------------------------------------------------
--on_click)
	RUN_ACTION  $Action
	DRAW $Drawing
	echo -n "x" > $ActivityFile
	exit 0
	;;
#------------------------------------------------------------------------------
--refresh)
	$0 --get_service_list
	$0 --collect
	$0 --draw
	DRAW $Drawing
	echo -n "x" > $ActivityFile
	exit 0
	;;
#------------------------------------------------------------------------------
--page)
	DRAW $Drawing
	echo -n "x" > $ActivityFile
	exit 0
	;;
#------------------------------------------------------------------------------
--config_head_css)
	echo "<link rel=\"stylesheet\" type="text/css" href=\"$SiteCss\" />"
	exit 0
	;;
--config_head_title)
	echo "<title>$T_SiteTitle</title>"
	exit 0
	;;
--config_head_refresh)
	if [ -f "$SiteRefreshPeriodFile" ] ; then
		SiteRefreshPeriod=`cat $SiteRefreshPeriodFile`
	fi
	case "$SiteRefreshPeriod" in
	0)
		;;
	*)
		echo "<meta http-equiv=\"Refresh\" content=\"$SiteRefreshPeriod\"/>"
		;;
	esac
	exit 0
	;;
--config_page_header)
	if [ -f $CustomPageHeaderConf ] ; then
		. $CustomPageHeaderConf
	fi
	case "$ServerMode" in
	demo|education)
		SiteName="$T_SiteNameAcademy"
		SiteSlogan="$T_SiteSloganAcademy"
		;;
	*|*business)
		SiteName="$T_SiteNameEnterprise"
		SiteSlogan="$T_SiteSloganEnterprise"
		;;
	esac
	SiteHeader="<div id=\"top_header\"><a href=\"$SiteUrl\"><div id=\"header\"><h1><span>$SiteName</span></h1><h2>$SiteSlogan</h2></div></a></div>"
	echo "$SiteHeader"
	exit 0
	;;
--config_welcome_message)
	#TR T_Welcome		Hello,&nbsp; : Bonjour,&nbsp;
	#TR T_DemoMessage	Demonstration Mode - Actions are not executed : Mode Demonstration - Les actions ne sont pas executees
	case "$ServerMode" in
	demo*)
		WelcomeMessage="$T_DemoMessage &nbsp;-&nbsp;$T_Welcome"
		;;
	*)
		WelcomeMessage="$T_Welcome"
		;;
	esac
	echo -n "$WelcomeMessage"
	exit 0
	;;
--config_page_footer)
	#TR T_Contact_us	CONTACT US : CONTACTEZ NOUS
	SiteFooter="<div id=\"footer\"><div id=\"block_contact_infos\">
<h4>$T_Contact_us</h4>
<strong>SISalp</strong><br/>		
Les Millieres<br/>
74230 SERRAVAL - FRANCE<br/>
Tel: +33 (0)622 616 438<br/>	
<a href=\"http://sisalp.fr\">sisalp.fr</a>
</div></div>"
	if [ -f $CustomPageFooterConf ] ; then
		. $CustomPageFooterConf
	fi
	echo "$SiteFooter"
	exit 0
	;;
--config_login_form)
	#TR T_User	User : Utilisateur
	#TR T_Password	Password : Mot de passe
	LoginForm="
		<form method=\"post\" action=\".\">
			<label for=\"login\">$T_User</label>&nbsp;<input type=\"text\" name='login' size=\"12\" required >&nbsp;&nbsp;&nbsp;
			<label for=\"pass\">$T_Password</label>&nbsp;<input type=\"password\" name='pass' size=\"12\" required >&nbsp;&nbsp;&nbsp;
			<img src=\"images/fr.jpg\"> <input name=\"language\" type=\"radio\" value=\"fr\" checked=\"yes\">
			<img src=\"images/en.jpg\"> <input name=\"language\" type=\"radio\" value=\"en\">&nbsp;&nbsp;&nbsp;
			<img src=\"images/login.gif\" alt=\"Log me in\" title=\"Log me in\" />&nbsp;&nbsp;&nbsp;
			<input type=\"submit\" name=\"connect\" value=\"Login\">
		</form>"
	echo -n "$LoginForm"
	exit 0
	;;
--config_denied_message)
	#TR T_Access_denied Access denied. Please try again : Acces refuse. Veuillez essayer de nouveau
	DeniedMessage="<p>$T_Access_denied</p>"
	echo -n "$DeniedMessage"
	exit 0
	;;
--config_login_footer)
	#TR T_Test_bandwith	Test current bandwidth from server : Testez le debit actuel du serveur
	#TR T_start_test	start test : demarrer le test
	PerformanceScript="<script type=\"text/javascript\">
//<!--
var image = 'images/testimage.jpg';
var size = 620;
var time1 = 0;
var time2 = 0;
function start_test_vitesse()
{
time1 = new Date();
time1 = time1.getTime();
var img = new Image();
img.src = image+'?'+time1;
img.onload=end_test_vitesse;
}
function end_test_vitesse()
{
var time2 = new Date();
time2 = time2.getTime();
var ms = time2-time1;
var vitesse = Math.round(size/ms*800)/100;
document.getElementById('vitesse').value=vitesse+' Mb/s';
}
//-->
</script>"
	LoginFooter="<div id=\"footer\"><div id=\"block_performance\">
$PerformanceScript
$T_Test_bandwith<br/><br/><input type=\"button\" value=\"$T_start_test\" onclick=\"javascript:start_test_vitesse();\" />&nbsp;&nbsp;&nbsp;<input type=\"text\" id=\"vitesse\" size=\"16\" /><br/><br/></div></div> <!-- footer -->"
	echo "$LoginFooter"
	exit 0
	;;
--config_page_menu)
	#TR T_Help		Help : Aide
	#TR T_Support		Support : Support
	#TR T_Show		Show : Afficher
	#TR T_Hide		Hide : Masquer
	#TR T_SH_options	options : les options
	#TR T_SH_admin_guide	administration guide : le guide d administration
	#TR T_SH_contract	contract info : le contrat
	#TR T_SH_openservice	open service : nouveau service
	#TR T_SH_closeservice	close service : cloture de service
	#TR T_SH_monitor	system status : l'etat du system
	#TR T_SH_mooc		mooc courses : les cours mooc
	#TR T_SH_services	services details: les details des services
	#TR T_SH_log		log messages : les messages du log
	#TR T_Compose_main_page	Compose this general dashboard : Composer ce tableau de bord
	#TR T_Service_list_title	Go to services detailled information : Acces aux fiches detaillees des services
	

	LOG_MESSAGE $LINENO -g config_page_menu LoginUser $LoginUser LoginPassword $LoginPassword LoginRole $LoginRole
	case "$LoginUser" in
	Admin*|admin*)


		ServicesMenu=`cat $GoeDir/goe.menu.draw`
#	SiteMenu="<div id=\"menu\"><a target=\"_blank\" href=\"$SiteAbout\"><div class=\"menu_element\"><div class=\"static\"> $T_Help </div></div></a><a target=\"_blank\" href=\"$SiteSupport\"><div class=\"menu_element\"><div class=\"static\"> $T_Support </div></div></a><a target=\"_blank\" href=\"$SiteSupport\"><div class=\"menu_element\"><div class=\"static\"> $T_Show... </div></div></a> $ServicesMenu"
		case "$ServerMenuMode" in
		show)
			SiteMenu="
<div class=\"dashboard_title\">$T_Compose_main_page</div>
<div class=\"menu\">"

			case "$ServerMenuEnabled" in
			*help*)
				SiteMenu="$SiteMenu
<a target=\"_blank\" href=\"$SiteAbout\"><div class=\"menu_element\"><div class=\"static\"> $T_Help </div></div></a>"
				;;
			esac
			case "$ServerMenuEnabled" in
			*support*)
				SiteMenu="$SiteMenu
<a target=\"_blank\" href=\"$SiteSupport\"><div class=\"menu_element\"><div class=\"static\"> $T_Support </div></div></a>"
				;;
			esac
			case "$ServerMenuEnabled" in
			*options*)
				SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard options hide\" title=\"$T_Hide $T_SH_options\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_options </div></div></a>"
				;;


			esac


			case "$ServerContractMode" in
			show)
				case "$ServerMenuEnabled" in
				*contract*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard contract hide\" title=\"$T_Hide $T_SH_contract\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_contract </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*contract*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard contract show\" title=\"$T_Show $T_SH_contract\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_contract </div></div></a>"
					;;
				esac
				;;
			esac
			case "$AdminGuideMode" in
			show)
				case "$ServerMenuEnabled" in
				*admin_guide*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard admin_guide hide\" title=\"$T_Hide $T_SH_admin_guide\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_admin_guide </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*admin_guide*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard admin_guide show\" title=\"$T_Show $T_SH_admin_guide\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_admin_guide </div></div></a>"
					;;
				esac
				;;
			esac
			case "$OpenServiceMode" in
			show)
				case "$ServerMenuEnabled" in
				*openservice*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard openservice hide\" title=\"$T_Hide $T_SH_openservice\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_openservice </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*openservice*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard openservice show\" title=\"$T_Show $T_SH_openservice\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_openservice </div></div></a>"
					;;
				esac
				;;
			esac


			case "$CloseServiceMode" in
			show)
				case "$ServerMenuEnabled" in
				*closeservice*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard closeservice hide\" title=\"$T_Hide $T_SH_closeservice\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_closeservice </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*closeservice*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard closeservice show\" title=\"$T_Show $T_SH_closeservice\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_closeservice </div></div></a>"
					;;
				esac
				;;
			esac

			case "$SystemInfoMode" in
			show)
				case "$ServerMenuEnabled" in
				*monitor*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard monitor hide\" title=\"$T_Hide $T_SH_monitor\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_monitor </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*monitor*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard monitor show\" title=\"$T_Show $T_SH_monitor\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_monitor </div></div></a>"
					;;
				esac
				;;
			esac
			case "$MoocInfoMode" in
			show)
				case "$ServerMenuEnabled" in
				*mooc*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard mooc hide\" title=\"$T_Hide $T_SH_mooc\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_mooc </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*mooc*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard mooc show\" title=\"$T_Show $T_SH_mooc\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_mooc </div></div></a>"
					;;
				esac
				;;
			esac

			case "$ServiceDetailsMode" in
			show)
				case "$ServerMenuEnabled" in
				*services*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard services hide\" title=\"$T_Hide $T_SH_services\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_services </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*services*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard services show\" title=\"$T_Show $T_SH_services\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_services </div></div></a>"
					;;
				esac
				;;
			esac

			case "$ServerLogMode" in
			show)
				case "$ServerMenuEnabled" in
				*log*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard log hide\" title=\"$T_Hide $T_SH_log\"><div class=\"menu_element\"><div class=\"static\"> $T_Hide $T_SH_log </div></div></a>"
					;;
				esac
				;;

			*)
				case "$ServerMenuEnabled" in
				*log*)
					SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard log show\" title=\"$T_Show $T_SH_log\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_log </div></div></a>"
					;;
				esac
				;;
			esac
			SiteMenu="$SiteMenu
</div>
<div class=\"dashboard_title\">$T_Service_list_title</div>
<div class=\"menu\">
$ServicesMenu"	
			;;
		hide)
			SiteMenu="
<div class=\"menu\">"
			case "$ServerMenuEnabled" in
			*help*)
				SiteMenu="$SiteMenu
<a target=\"_blank\" href=\"$SiteAbout\"><div class=\"menu_element\"><div class=\"static\"> $T_Help </div></div></a>"
				;;
			esac
			case "$ServerMenuEnabled" in
			*support*)
				SiteMenu="$SiteMenu
<a target=\"_blank\" href=\"$SiteSupport\"><div class=\"menu_element\"><div class=\"static\"> $T_Support </div></div></a>"
				;;
			esac
			case "$ServerMenuEnabled" in
			*options*)
				SiteMenu="$SiteMenu
<a href=\"../index.php?action=--on_click dashboard_menu dashboard goe --dashboard options show\" title=\"$T_Show $T_SH_options\"><div class=\"menu_element\"><div class=\"static\"> $T_Show $T_SH_options </div></div></a>"
				;;
			esac
			SiteMenu="$SiteMenu
$ServicesMenu"
			;;
		esac
		;;
	*)
		SiteMenu="
<div class=\"menu\">"
		case "$ServerMenuEnabled" in
		*help*)
			SiteMenu="$SiteMenu
<a target=\"_blank\" href=\"$SiteAbout\"><div class=\"menu_element\"><div class=\"static\"> $T_Help </div></div></a>"
			;;
		esac
		case "$ServerMenuEnabled" in
		*support*)
			SiteMenu="$SiteMenu
<a target=\"_blank\" href=\"$SiteSupport\"><div class=\"menu_element\"><div class=\"static\"> $T_Support </div></div></a>"
			;;
		esac
		;;
	esac
	echo "$SiteMenu"
	exit 0
	;;
#------------------------------------------------------------------------------
--config_mode)
	echo "$ServerMode"
	exit 0
	;;
#------------------------------------------------------------------------------
--version)
	case "$BlablaVersion" in
	-noblabla)
		echo "<!-- goe version is $ThisScriptVersion -->"
		;;
	*)
		echo "<!-- goe version is $GoeVersion -->"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--clean)
	CHECK_BUZY $LINENO
	rm -f $ActivityFile
	rm -rf $Drawings
	rm -rf $Actions
	rm -rf $Templates
	rm -rf $GoeData
	exit 0
	;;
#------------------------------------------------------------------------------
esac

#------------------------------------------------------------------------------
SHAPE_XML_FILE ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g  SHAPE_XML_FILE $*

#SHAPE_XML_FILE [comment] -XmlOption XmlZone [XmlFile]
xmlparamaters="$*"
case "$1" in
-*)
	;;
*)
	sxf_comment="$1"
	shift
	;;
esac
XmlOption="$1"
shift
case "$1" in
*/*|./*)
	XmlFile="$1"
	XmlZone="$2"
	;;
*)
	XmlFile="$2"
	XmlZone="$1"
	;;
esac
if [ ! -z "$XmlFile" ] ; then
	case "$XmlOption" in
	-new_page)
		echo "<!-- This file $XmlOption $XmlFile generated for $XmlZone by $0 on $Date mode $ServerMode parameters $sxf_comment -->
	<zone name=\"$XmlZone\">" > $XmlFile
		#echo "Draw $XmlOption $XmlFile for $XmlZone on $Date mode $ServerMode parameters $sxf_comment-$LINENO" >> $DrawingsLog
		
		;;
	-end_page)
		echo " <!-- end \"$XmlZone\" --> </zone>" >> $XmlFile
		;;
	-continue)
		;;
	-init)
		echo "<!-- This file $XmlOption $XmlFile generated for $XmlZone by $0 on $Date mode $ServerMode parameters $sxf_comment -->" > $XmlFile
		#echo "Draw $XmlOption $XmlFile for $XmlZone on $Date mode $ServerMode parameters $sxf_comment-$LINENO" >> $DrawingsLog
		;;
	*)
		LOG_MESSAGE $LINENO -g error $xmlparamaters
		;;
	esac
else
	case "$XmlOption" in
	-new_page)
		echo "<!-- This content $XmlOption online evaluated for $XmlZone on the fly by $0 on $Date mode $ServerMode parameters $sxf_comment -->
	<zone name=\"$XmlZone\">"
		#echo "On the fly $XmlOption evaluated for $XmlZone on $Date mode $ServerMode parameters $sxf_comment-$LINENO" >> $DrawingsLog

		;;
	-end_page)
		echo " <!-- end \"$XmlZone\" --> </zone>"
		;;
	-continue)
		;;
	-init)
		echo "<!-- This content $XmlOption online evaluated for $XmlZone on the fly by $0 on $Date mode $ServerMode parameters $sxf_comment -->"
		#echo "On the fly $XmlOption evaluated for $XmlZone on $Date mode $ServerMode parameters $sxf_comment-$LINENO" >> $DrawingsLog
		;;
	*)
		LOG_MESSAGE $LINENO -g error $xmlparamaters
		;;
	esac
fi
}
#end 
#------------------------------------------------------------------------------

case "$Option" in
#------------------------------------------------------------------------------
--init)
	$0 --get_service_list
	$0 --collect
	$0 --template
	$0 --draw
	exit 0
	;;
#------------------------------------------------------------------------------
--login)
	GET_XOE_DATA
	echo "<data>"
	for login_service in $ServiceList ; do
		GET_XOE_DATA $login_service
		if [ ! -z $LoginUser ] && [ ! -z $LoginPassword ] &&  [ ! -z $LoginRole ] ; then
			echo "    <user><login>$LoginUser</login><pass>$LoginPassword</pass><role>$LoginRole</role></user>"
		fi
	done

	old_IFS=$IFS
	IFS=$'\n'
	for ligne in $UserLogins ; do
		IFS=$old_IFS
		user_name=`echo "$ligne" | cut -d" " -f1`
		user_password=`echo "$ligne" | cut -d" " -f2`
		user_role=`echo "$ligne" | cut -d" " -f3`
		if [ ! -z $user_name ] && [ ! -z $user_password ] &&  [ ! -z $user_role ] ; then
			echo "    <user><login>$user_name</login><pass>$user_password</pass><role>$user_role</role></user>"
		fi
		IFS=$'\n'
	done
	IFS=$old_IFS
	echo "</data>"
	;;
#------------------------------------------------------------------------------
--template)

#------------------------------------------------------------------------------
TEMPLATE_ACTION ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g TEMPLATE_ACTION $* Mode $ServerMode
#TR T_Parameters_are_NOT_valid Sorry, your request cannot be processed. Return code is : Desole, le serveur refuse cette demande d'operation. Sa reponse est
#TR T_Technical_request For your information, the sent request is the following : Pour information, la requete emise est la suivante
#TR T_Acting Previous actiion did not complete yet : Une action precedente est encore en cours d'execution
#TR T_Language	/usr/local/etc/goe/goe.translation.en : /usr/local/etc/goe/goe.translation.fr
#TR T_submitted Action is submitted to server : L action est transmise au serveur
#TR T_completed	Action completed on server : L action a ete executee par le serveur
action_type="$1"
GetValues="#! /bin/bash
# generated by $0 on $Date mode $ServerMode
#-----------------
ACTION_GET_LANGUAGE ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- | grep \"^ServiceLanguage=\"\ > /tmp/goe.get_xoe_data.language.form.\$\$.sh
. /tmp/goe.get_xoe_data.language.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.language.form.\$\$.sh
language=\"\$ServiceLanguage\"
if [ -z \"\$language\" ] ; then
	language=\"en\"
fi
. $GoeTranslationFile.\$language
if [ -e $GoeCustomTranslationFile.\$language ] ; then
	. $GoeCustomTranslationFile.\$language
fi
}
#--------------------
ACTION_MESSAGE ()
#--------------------
{
case \"\$action\" in
--check)
	am_status=\"$T_submitted\"
	;;
--execute)
	am_status=\"$T_completed\"
	;;
esac
case \"\$1\" in
-a)
	shift
	echo \"\`date\`| \$* : \$am_status\" >> $GoeActionsLog
	;;
-e)
	shift
	echo \"ACTION \$LINENO|Error|\`date\`|\$0| \$*\" >> $GoeLog
	echo \"ACTION \$LINENO|Error|\`date\`|\$0| \$*\" >> $XoeLog
	;;
*)
	echo \"ACTION \$LINENO|Messg|\`date\`|\$0| \$*\" >> $GoeLog
	echo \"ACTION \$LINENO|Messg|\`date\`|\$0| \$*\" >> $XoeLog
	;;
esac
}
#--------------------
ACTION_GET_VALUE ()
#--------------------
{
if [ ! -z \"\$1\" ] ; then
	case \"\$1\" in
	*=*)
		echo \"\$*\" | cut -d= -f2
		 ;;
	*)
		echo \"\$*\"
		;;
	esac
fi
}
#--------------------
ACTION_CHECK ()
#--------------------
{
if [ -z \"\$2\" ] ; then
	ACTION_MESSAGE -e \"\$T_Parameters_are_NOT_valid $action_type : Uncorrect or missing \$1 parameter\"
	echo \"401: Action linked to button $action_type, action \$action mode \$mode : Uncorrect or missing \$1 parameter \$0 \$parameters\"
	echo \"....\"
	exit 4
else
	ACTION_MESSAGE  \"Wonderful parameter \$*\"
fi
}
#--------------------
ACTING ()
#--------------------
{
pending_action=\"\$*\"
for ((ia=1;ia<25;ia=ia+1)) ; do
	if [ -f $GoeActingFlag.\$service.flag ] ; then
		on_going_action=\`cat $GoeActingFlag.\$service.flag\`
		case \"\$pending_action\" in
		\$on_going_action)
			#repeated action
			ACTION_MESSAGE  \"repeated action \$pending_action is cancelled\"
			echo \"repeated action \$pending_action is cancelled\" >> $GoeActingFlag.\$service.flag.log
			break
			;;
		*)
			#overlapping actions
			ACTION_MESSAGE  \"action \$pending_action is postponed because \$on_going_action is still processing\"
			echo \"action \$pending_action is postponed because \$on_going_action is still processing\" >> $GoeActingFlag.\$service.flag.log
			;;
		esac
	else
		echo \"\$pending_action\" > $GoeActingFlag.\$service.flag
		echo \"Starting \$pending_action\" >> $GoeActingFlag.\$service.flag.log
		ACTION_MESSAGE  \"Starting \$pending_action\"
		\$pending_action
		rm -f $GoeActingFlag.\$service.flag
		echo \"Completed \$pending_action\" >> $GoeActingFlag.\$service.flag.log
		ACTION_MESSAGE  \"Completed \$pending_action\"
		break
	fi
sleep $i
done
}
#--------------------
ACTION_EXECUTE ()
#--------------------
{
case \"\$action\" in
--check)
	case \"\$mode\" in
	demo*)
		echo \"Simulation of action linked to button \$action_type : \$T_Parameters_are_valid<br/> \$0 \$*\"
		ACTION_MESSAGE \"Info : \`date\` OK : Parameters are valid for Simulation of action $action_type : \$0 \$*\"
		;;
	*)
		echo \"<br/><small>\$T_Technical_request :<br/> \$0 \$*</small>\"
		ACTION_MESSAGE \"Info : \`date\` OK : Parameters are valid for Action $action_type : \$0 \$*\"
		;;
	esac
	;;
--execute)
	case \"\$mode\" in
	demo*)
		ACTION_MESSAGE \"Info : \`date\` Simulate Action $action_type : \$0 \$*\"
		;;
	*)
		ACTION_MESSAGE \"Info : \`date\` Execute Action $action_type : \$0 \$*\"
		ACTING \$*
		;;
	esac
	;;
esac
}
#--------------------
parameters=\"\$*\"
ACTION_MESSAGE ==========Action \$0 call parameters \$*
action=\"\$1\"
shift
#--------------------
mode=\"\$1\"
shift
#--------------------
service=\`ACTION_GET_VALUE \$1\`
shift
#--------------------
actingsignal=\`ACTION_GET_VALUE \$1\`
database=\`ACTION_GET_VALUE \$1\`
dropprefix=\`ACTION_GET_VALUE \$*\`
mooc_name=\`ACTION_GET_VALUE \$1\`
modelversion=\`ACTION_GET_VALUE \$1\`
archive_name=\`ACTION_GET_VALUE \$1\`
menu_name=\`ACTION_GET_VALUE \$1\`
month=\`ACTION_GET_VALUE \$1\`
shift
#--------------------
archive=\`ACTION_GET_VALUE \$1\`
mooc_action=\`ACTION_GET_VALUE \$1\`
exam_action=\`ACTION_GET_VALUE \$1\`
archive_action=\`ACTION_GET_VALUE \$1\`
admin_password=\`ACTION_GET_VALUE \$2\`
cloneprefix=\`ACTION_GET_VALUE \$*\`
copyservice=\`ACTION_GET_VALUE \$1\`
copyprefix=\`ACTION_GET_VALUE \$2\`
mooc_min=\`ACTION_GET_VALUE \$2\`
mooc_max=\`ACTION_GET_VALUE \$3\`
mooc_mail=\`ACTION_GET_VALUE \$4\`
exam_login=\`ACTION_GET_VALUE \$2\`
exam_password=\`ACTION_GET_VALUE \$3\`
menu_content=\`ACTION_GET_VALUE \$*\`
period=\`ACTION_GET_VALUE \$1\`
shift
#--------------------
company=\`ACTION_GET_VALUE \$*\`
#--------------------
ACTION_GET_LANGUAGE
"

case "$action_type" in
#------------
#Service Actions
#------------
button_editservicemenu)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_CHECK menu_name \$menu_name
ACTION_CHECK menu_content \$menu_content
ACTION_EXECUTE sudo /usr/local/bin/xoe --config -set -panel \$menu_name \$service editservicemenu \$menu_content
ACTION_EXECUTE sudo /usr/local/bin/goe --get_service_list
ACTION_MESSAGE -a Action:\$service: $T_Service_menu_action \$service: \$menu_content
exit 0" > $Actions.draft/$action_type.template
	;;
button_renew)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_EXECUTE sudo /usr/local/bin/xoe log -last -set \$service today
ACTION_EXECUTE sudo /usr/local/bin/goe --get_service_list
ACTION_MESSAGE -a Action:\$service: $T_Renew_service
exit 0" > $Actions.draft/$action_type.template
	;;
button_start)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_EXECUTE sudo /usr/local/bin/xoe start \$service
ACTION_EXECUTE sudo /usr/local/bin/xoe config -set -auto \$service
ACTION_EXECUTE sudo /usr/local/bin/goe --get_service_list
ACTION_MESSAGE -a Action:\$service: $T_Start_service
exit 0" > $Actions.draft/$action_type.template
	;;
button_stop)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_EXECUTE sudo /usr/local/bin/xoe config -set -manual \$service
ACTION_EXECUTE sudo /usr/local/bin/xoe stop \$service
ACTION_EXECUTE sudo /usr/local/bin/goe --get_service_list
ACTION_MESSAGE -a Action:\$service: $T_Stop_service
exit 0" > $Actions.draft/$action_type.template
	;;
button_restart)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_EXECUTE sudo /usr/local/bin/xoe restart \$service
ACTION_EXECUTE sudo /usr/local/bin/goe --get_service_list
ACTION_MESSAGE -a Action:\$service: $T_Restart_service
exit 0" > $Actions.draft/$action_type.template
	;;
button_newcase)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_CHECK archive \$archive
	ACTION_CHECK admin_password \$admin_password
	ACTION_EXECUTE sudo /usr/local/bin/xoe database -restore -force \$service \$database \$archive
	ACTION_EXECUTE sudo /usr/local/bin/xoe database -admin_password \$service \$database \$admin_password
	ACTION_MESSAGE -a Action:\$service: $T_Use_a_case \$database \$archive
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_company)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_CHECK company \"\$company\"
ACTION_CHECK month \$month
ACTION_CHECK period \$period
echo \"sudo /usr/local/bin/xoe database -script \$service populate_fr.script \$month \$period \$company \" >> /tmp/button_company.log
ACTION_EXECUTE sudo /usr/local/bin/xoe database -script \$service populate_fr.script \$month \$period \"\$company\"
ACTION_MESSAGE -a Action:\$service: $T_Set_a_company \"\$company\"
exit 0" > $Actions.draft/$action_type.template
	;;
button_newmooc)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK mooc_name \$mooc_name
	ACTION_CHECK archive \$archive
	ACTION_CHECK mooc_min \$mooc_min
	ACTION_CHECK mooc_max \$mooc_max
	ACTION_CHECK mooc_mail \$mooc_mail
	ACTION_EXECUTE sudo /usr/local/bin/mooc --create \$service \$mooc_name \$archive \$mooc_min \$mooc_max \$mooc_mail
	ACTION_MESSAGE -a Action:\$service: $T_New_Mooc_doc \$mooc_name \$archive \$mooc_min \$mooc_max \$mooc_mail
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_managemooc)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK mooc_name \$mooc_name
	ACTION_CHECK mooc_action \$mooc_action
	ACTION_EXECUTE sudo /usr/local/bin/mooc \$mooc_action \$service \$mooc_name
	ACTION_MESSAGE -a Action:\$service: $T_Manage_Mooc_doc \$mooc_name: \$mooc_action
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_exam)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK mooc_name \$mooc_name
	ACTION_CHECK exam_action \$exam_action
	ACTION_CHECK exam_login \$exam_login
	ACTION_CHECK exam_password \$exam_password
	ACTION_EXECUTE sudo /usr/local/bin/mooc \$exam_action \$service \$mooc_name \$exam_login \$exam_password
	ACTION_MESSAGE -a Action:\$service: $T_Exam_doc \$mooc_name \$exam_action
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_upload)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	#add new archives to service and filter names with spaces
	ACTION_MESSAGE \"U ACTION_EXECUTE sudo /usr/local/bin/goe --shell_move $GoeUploads/\$service $XoeDir/xoe.services/\$service/custom\"
	ACTION_EXECUTE sudo /usr/local/bin/goe --shell_move $GoeUploads/\$service $XoeDir/xoe.services/\$service/custom
	ACTION_MESSAGE -a Action:\$service: $T_Upload_doc
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_installarchive)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK archive_name \$archive_name
	ACTION_CHECK archive_action \$archive_action
	case \"\$archive_action\" in
	--remove)
		ACTION_MESSAGE \"A action \$action mode \$mode service \$service archive_name \$archive_name archive_action \$archive_action \$service ACTION_EXECUTE sudo /usr/local/bin/goe --shell rm \$archive_name\"
		ACTION_EXECUTE sudo /usr/local/bin/goe --shell rm \$archive_name
		ACTION_MESSAGE -a Action:\$service: $T_Installarchive_doc \$service REMOVE \$archive_name
		;;
	--directory)
		ACTION_MESSAGE \"B ACTION_EXECUTE sudo /usr/local/bin/xoe \$archive_action -add-archive \$service \$archive_name\"
		ACTION_EXECUTE sudo /usr/local/bin/xoe \$archive_action -add-archive \$service \$archive_name
		ACTION_MESSAGE -a Action:\$service: $T_Installarchive_doc IMPLEMENT \$archive_name
		;;
	esac
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_upgrade)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK modelversion \$modelversion
	ACTION_EXECUTE sudo /usr/local/bin/xoe config -set -manual \$service
	ACTION_EXECUTE sudo /usr/local/bin/xoe contract -upgrade \$service \$modelversion
	ACTION_EXECUTE sudo /usr/local/bin/xoe config -set -auto \$service
	ACTION_MESSAGE -a Action:\$service: $T_Upgrade_doc \$modelversion
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_downgrade)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_EXECUTE sudo /usr/local/bin/xoe directory -downgrade \$service
	ACTION_MESSAGE -a Action:\$service: $T_Downgrade_doc
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_drop)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK dropprefix \$dropprefix
	ACTION_EXECUTE sudo /usr/local/bin/xoe database -drop -prefix \$service \$dropprefix
	ACTION_MESSAGE -a Action:\$service: $T_Drop_doc \$dropprefix
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;

#-------------
#Database Actions
#-------------
button_editdatabasemenu)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_CHECK menu_name \$menu_name
ACTION_CHECK menu_content \$menu_content
ACTION_EXECUTE sudo /usr/local/bin/xoe --config -set -panel \$menu_name \$service editdatabasemenu \$menu_content
ACTION_EXECUTE sudo /usr/local/bin/goe --get_service_list
ACTION_MESSAGE -a Action:\$service: $T_Database_menu_action \$service: \$menu_content
exit 0" > $Actions.draft/$action_type.template
	;;
button_save)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_CHECK database \$database
ACTION_EXECUTE sudo /usr/local/bin/xoe database -save -now \$service \$database
ACTION_MESSAGE -a Action:\$service:\$database: $T_Save_database
exit 0" > $Actions.draft/$action_type.template
	;;
button_snapshot)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
ACTION_CHECK database \$database
ACTION_EXECUTE sudo /usr/local/bin/xoe config -snapshot -on \$service \$database
ACTION_MESSAGE -a Action:\$service:\$database: $T_Snapshot_database
exit 0" > $Actions.draft/$action_type.template
	;;
button_restore)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_CHECK archive \$archive
	ACTION_EXECUTE sudo /usr/local/bin/xoe database -restore -force \$service \$database \$archive
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Restore_database \$database \$archive
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_clone)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_CHECK cloneprefix \$cloneprefix
	ACTION_EXECUTE sudo /usr/local/bin/xoe database -clone \$service \$database \$cloneprefix
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Clone_database \$cloneprefix
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_copy)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_CHECK copyservice \$copyservice
	ACTION_CHECK copyprefix \$copyprefix
	ACTION_EXECUTE sudo /usr/local/bin/xoe database -copy -force \$service \$database \$copyservice \$copyprefix
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Copy_database \$copyservice \$copyprefix
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_reference)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_EXECUTE sudo  /usr/local/bin/xoe database -set -data \$service \$database
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Reference_database $T_on_service \$service
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_delete)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_EXECUTE sudo  /usr/local/bin/xoe database -drop -db \$service \$database
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Delete_database
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_wipe_out)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_EXECUTE sudo  /usr/local/bin/xoe database -archive -wipe-out \$service \$database
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Delete_archives_of_database
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
button_dbupdate)
	echo "$GetValues
ACTION_CHECK action \$action
ACTION_CHECK mode \$mode
ACTION_CHECK service \$service
case \"\$actingsignal\" in
clear)
	ACTION_EXECUTE sudo rm -f $GoeActingFlag.\$service.flag
	;;
wait)
	;;
*)
	ACTION_CHECK database \$database
	ACTION_EXECUTE sudo  /usr/local/bin/xoe database -update \$service \$database
	ACTION_MESSAGE -a Action:\$service:\$database: $T_Update_database
	;;
esac
exit 0" > $Actions.draft/$action_type.template
	;;
*)
	LOG_MESSAGE $LINENO -g TEMPLATE_ACTION $* Mode $ServerMode ERROR
	;;
esac
chmod 600 $Actions.draft/$action_type.template
}
#end 
#------------------------------------------------------------------------------
TEMPLATE_BUTTON_RESULT ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g TEMPLATE_BUTTON_RESULT $*
#TR T_Action_Report_Message Action Report Message : Compte-rendu de l'action
#TR T_Action_return_message Your request is now processing : Votre requete a ete transmise au serveur
#TR T_Parameters_are_valid Thank you for your patience until action menu above is refreshed : Merci de patienter jusqu au reaffichage du menu ci dessus
#TR T_menu_lock_released or lock on menu has been released : ou le blocage des menu a ete leve
button_type="$1"
result_template="$2"
case "$button_type" in
#------------
#Service Results
#------------
button_editservicemenu|button_renew|button_start|button_stop|button_restart|button_newcase|button_company|button_drop|button_newmooc|button_managemooc|button_exam|button_upload|button_installarchive|button_upgrade|button_downgrade)

	ResultGenerics="
#-----------------
SERVICE_RESULT_GET_LANGUAGE ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- | grep \"^ServiceLanguage=\"\ > /tmp/goe.get_xoe_data.language.form.\$\$.sh
. /tmp/goe.get_xoe_data.language.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.language.form.\$\$.sh
language=\"\$ServiceLanguage\"
if [ -z \"\$language\" ] ; then
	language=\"en\"
fi
. $GoeTranslationFile.\$language
if [ -e $GoeCustomTranslationFile.\$language ] ; then
	. $GoeCustomTranslationFile.\$language
fi
}
#-----------------
SERVICE_RESULT_CAT ()
#-----------------
{
for ((ic=0;ic<50;ic=ic+1)) ; do
	if cat \$1 ; then
		break
	fi
	sleep 0.1
done
}
#-----------------
SERVICE_RESULT_GENERICS ()
#-----------------
{
echo \"
<zone name=\\\"zone.\$Service.${button_type}_result\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"$SiteRefreshResult; url=../index.php?action=--page zone.\$Service.map \$Service.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$*</title>]]></zone_title>
	<zone_type>button_result</zone_type>
	<zone_status>ok</zone_status>
	<zone_html><![CDATA[ \$T_Action_Report_Message<br/>\$T_Action_return_message : \$T_Parameters_are_valid <br/>\$*<br/>\$ActionMessage<br/> ]]></zone_html>\"
}
#-----------------"
	ResultTop="SERVICE_RESULT_TOP_WINDOW ()
#-----------------
{
echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->\"
SERVICE_RESULT_CAT $Drawings/\$Service.menu.draw | sed s:'<zone_status>ok</zone_status>':'<zone_status>unknown</zone_status>':
echo \"<hr/>\"
}
#-----------------"
	ResultBottom="SERVICE_RESULT_BOTTOM ()
#-----------------
{
echo \"<!-- end zone.\$Service.${button_type}_result --> </zone>\"
SERVICE_RESULT_CAT $Drawings/\$Service.info.draw
echo \" <!-- addendum Result -->\"
}
#-----------------
SERVICE_RESULT_GET_LANGUAGE
#-----------------"
	#TR T_Service Service : Le service
	case "$button_type" in
	button_editservicemenu)
		#TR T_Set_service_menu_result Operation is being processed on service : L'operation demandee est en cours sur le service
		ResultTitle="\$T_Set_service_menu_result \$Service"
		;;
	button_renew)
		#TR T_is_renewed_result is renewed for a contractual period : est reconduit pour sa duree contractuelle
		ResultTitle="\$T_Service \$Service \$T_is_renewed_result"
		;;
	button_start)
		#TR T_is_started_result is started : est demarre
		ResultTitle="\$T_Service \$Service \$T_is_started_result"
		;;
	button_stop)
		#TR T_is_stopped_result is stopped : est arrete
		ResultTitle="\$T_Service \$Service \$T_is_stopped_result"
		;;
	button_restart)
		#TR T_is_restarted_result is restarted : est redemarre
		ResultTitle="\$T_Service \$Service \$T_is_restarted_result"
		;;
	button_newcase)
		#TR T_A_new_case_result A new case : Un nouveau cas
		#TR T_is_created_result is created : est cree
		ResultTitle="\$T_A_new_case_result \$T_on_service \$Service \$T_is_created_result \$T_menu_lock_released"
		;;
	button_company)
		#TR T_A_new_company_result A new company profile : Un nouveau profil de societe
		ResultTitle="\$T_A_new_company_result \$T_on_service \$Service \$T_is_created_result"
		;;
	button_drop)
		#TR T_Dropped_result Specified databases are dropped on service : Les bases de donneees specifiees sont supprimees sur le service
		ResultTitle="\$T_Dropped_result \$Service"
		;;
	button_newmooc)
		#TR T_A_new_moo_result A new mooc : Le nouveau cours
		ResultTitle="\$T_A_new_mooc_result \$MoocName \$T_on_service \$Service \$T_is_created_result \$T_menu_lock_released"
		;;
	button_managemooc)
		#TR T_Manage_mooc_result Operation is being processed on service : L'operation demandee est en cours sur le service
		ResultTitle="\$T_Manage_mooc_result \$Service \$T_menu_lock_released"
		;;
	button_exam)
		#TR T_Exam_result Operation is being processed on service : L'operation demandee est en cours sur le service
		ResultTitle="\$T_Exam_result \$Service \$T_menu_lock_released"
		;;
	button_upload)
		#TR T_archive_uploaded_result archive uploaded to : archive telechargee sur le
		ResultTitle="\$T_archive_uploaded_result \$T_Service \$Service  \$T_menu_lock_released"
		;;
	button_installarchive)
		#TR T_archive_operation_result Operation is being processed on service : L'operation demandee est en cours sur le service
		ResultTitle="\$T_Archive_operation_result \$Service \$T_menu_lock_released"
		;;
	button_upgrade)
		#TR T_upgraded_to_new_version_result upgraded to a new version : monte vers une nouvelle version
		ResultTitle="\$T_Service \$Service \$T_is \$T_upgraded_to_new_version_result \$T_menu_lock_released"
		;;
	button_downgrade)
		#TR T_reverted_back_to_previous_version_result reverted back to previous version : a ete retabli dans sa version precedente
		ResultTitle="\$T_Service \$Service \$T_reverted_back_to_previous_version_result \$T_menu_lock_released"
		;;
	esac
	echo "#! /bin/bash
$ResultGenerics
$ResultTop
$ResultBottom
SERVICE_RESULT_TOP_WINDOW
SERVICE_RESULT_GENERICS \"$ResultTitle\"
SERVICE_RESULT_BOTTOM
" > $Templates.draft/$result_template
	;;
#-------------
#Database Results
#-------------
button_editdatabasemenu|button_save|button_snapshot|button_restore|button_clone|button_copy|button_reference|button_delete|button_wipe_out|button_dbupdate)
	ResultGenerics="
#-----------------
DATABASE_RESULT_GET_LANGUAGE ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- | grep \"^ServiceLanguage=\"\ > /tmp/goe.get_xoe_data.language.form.\$\$.sh
. /tmp/goe.get_xoe_data.language.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.language.form.\$\$.sh
language=\"\$ServiceLanguage\"
if [ -z \"\$language\" ] ; then
	language=\"en\"
fi
. $GoeTranslationFile.\$language
if [ -e $GoeCustomTranslationFile.\$language ] ; then
	. $GoeCustomTranslationFile.\$language
fi
}
#-----------------
DATABASE_RESULT_CAT ()
#-----------------
{
for ((ib=0;ib<50;ib=ib+1)) ; do
	if cat \$1 ; then
		break
	fi
	sleep 0.1
done
}
#-----------------
DATABASE_RESULT_GENERICS ()
#-----------------
{
echo \"
<zone name=\\\"zone.\$Service.\$Database.${button_type}_result\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"$SiteRefreshResult; url=../index.php?action=--page zone.\$Service.\$Database.map \$Service.\$Database.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$1</title>]]></zone_title>
	<zone_type>button_result</zone_type>
	<zone_status>ok</zone_status>
	<zone_html><![CDATA[ \$T_Action_Report_Message<br/>\$T_Action_return_message : \$T_Parameters_are_valid <br/>\$*<br/>\$ActionMessage<br/> ]]></zone_html>\"
}
#-----------------"
	ResultTop="DATABASE_RESULT_TOP_WINDOW ()
#-----------------
{
echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->\"
DATABASE_RESULT_CAT $Drawings/\$Service.\$Database.menu.draw | sed s:'<zone_status>ok</zone_status>':'<zone_status>unknown</zone_status>':
}
#-----------------"
	ResultBottom="DATABASE_RESULT_BOTTOM ()
#-----------------
{
echo \"<!-- end zone.\$Service.\$CommentDatabase.${button_type}_result --> </zone>\"
DATABASE_RESULT_CAT $Drawings/\$Service.\$Database.info.draw
echo \"<!-- addendum Result -->\"
}
#-----------------
DATABASE_RESULT_GET_LANGUAGE
#-----------------"
	#TR T_Database		Database : La base de donnees
	#TR T_on_service	on service : du service
	#TR T_of_database	of database : de la base de donnees
	case "$button_type" in
	button_editdatabasemenu)
		#TR T_Set_database_menu Operation is being processed on service : L'operation demandee est en cours sur le service
		ResultTitle="\$T_Set_database_menu \$Service"
		;;
	button_save)
		#TR T_is_saved		is saved : est sauvegardee
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_saved \$T_menu_lock_released"
		;;
	button_snapshot)
		#TR T_is_auto_saved	is periodically saved : est auvegardee periodiquement
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_auto_saved \$T_menu_lock_released"
		;;
	button_restore)
		#TR T_Archive		Archive : La sauvegarde
		#TR T_is_restored	is restored : est restauree
		ResultTitle="\$T_Archive \$T_of_database \$Database \$T_on_service \$Service \$T_is_restored \$T_menu_lock_released"
		;;
	button_clone)
		#TR T_is_cloned		is cloned : est clonee
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_cloned \$T_menu_lock_released"
		;;
	button_copy)
		#TR T_is_copied		is copied : est copiee
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_copied \$T_menu_lock_released"
		;;
	button_reference)
		#TR T_is_referenced	is set as reference case : est referencee parmi les cas
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_referenced \$T_menu_lock_released"
		;;
	button_delete)
		#TR T_is_cancelled	is cancelled : est supprimee
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_cancelled \$T_menu_lock_released"
		;;
	button_wipe_out)
		#TR T_All_archives	All archives : Toutes les sauvegardes
		#TR T_are_removed	are removed : sont effacees
		ResultTitle="\$T_All_archives \$T_of_database \$Database \$T_on_service \$Service \$T_are_removed \$T_menu_lock_released"
		;;
	button_dbupdate)
		#TR T_is_updated	is updated : est mise a jour
		ResultTitle="\$T_Database \$Database \$T_on_service \$Service \$T_is_updated \$T_menu_lock_released"
		;;
	esac
	echo "#! /bin/bash
$ResultGenerics
$ResultTop
$ResultBottom
DATABASE_RESULT_TOP_WINDOW
DATABASE_RESULT_GENERICS \"$ResultTitle\"
DATABASE_RESULT_BOTTOM
" > $Templates.draft/$result_template
	;;
*)
	LOG_MESSAGE $LINENO -g TEMPLATE_BUTTON_RESULT $* ERROR
	;;
esac
chmod 600 $Templates.draft/$result_template
}
#end 
#------------------------------------------------------------------------------
TEMPLATE_BUTTON_FORM ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g TEMPLATE_BUTTON_FORM $*
# GET_DATA -service and eventually GET_DATA -database is already executed, so all variables are available
		#TR T_Processing	A previous action is still processing or never ended and blocks button : Une precedente action est encore en cours ou ne s est jamais terminee et bloque le bouton

		#TR T_Clear_acting_signal	A processing operation blocks the menu : Une operation inachevee bloque le menu
		#TR T_Acting_wait	Wait until processing action ends : Attendre la fin de l operation en cours
		#TR T_Acting_clear	Unlock menus : Debloquer les menus
		#TR T_Superceed_acting_signal	Concurrent operations on a database may fail : Des operations simultanees sur une base de donnees peuvent echouer
button_type="$1"
form_template="$2"
#pre-created sections of code
case "$button_type" in
#------------
#Service Forms
#------------
#some buttons (start, stop etc..) don't need a form
button_editservicemenu|button_newcase|button_company|button_drop|button_newmooc|button_managemooc|button_exam|button_upload|button_installarchive|button_upgrade|button_downgrade)
	#new case is related to a service, not a database
	FormServiceGenerics="
#-----------------
SERVICE_GET_LANGUAGE ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- | grep \"^ServiceLanguage=\"\ > /tmp/goe.get_xoe_data.language.form.\$\$.sh
. /tmp/goe.get_xoe_data.language.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.language.form.\$\$.sh
language=\"\$ServiceLanguage\"
if [ -z \"\$language\" ] ; then
	language=\"en\"
fi
. $GoeTranslationFile.\$language
if [ -e $GoeCustomTranslationFile.\$language ] ; then
	. $GoeCustomTranslationFile.\$language
fi
}
#-----------------
SERVICE_CAT ()
#-----------------
{
for ((isc=0;isc<50;isc=isc+1)) ; do
	if cat \$1 ; then
		break
	fi
	sleep 0.1
done
}
#-----------------
SERVICE_FORM_TOP_WINDOW ()
#-----------------
{
echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->\"
SERVICE_CAT $Drawings/\$Service.menu.draw
}
#-----------------
SERVICE_FORM_GENERICS ()
#-----------------
{
echo \"
<zone name=\\\"zone.\$Service.${button_type}_form\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"180; url=../index.php?action=--page zone.\$Service.map \$Service.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$1</title>]]></zone_title>
	<zone_type>button_form</zone_type>
	<zone_status>ok</zone_status>
	<zone_on_validate>--on_click zone.\$Service.${button_type}_form \$Service.${button_type}_result.template \$Service.${button_type}.template</zone_on_validate>\"
}
#-----------------
SERVICE_FORM_BOTTOM ()
#-----------------
{
echo \"
<!-- end zone.\$Service.${button_type}_form --> </zone>
<!-- addendum form -->\"
SERVICE_CAT $Drawings/\$Service.info.draw
}
#-----------------
SERVICE_ON_ERROR ()
#-----------------
{
echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->
<zone name=\\\"zone.\$Service.${button_type}_form\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"$SiteRefreshResult; url=../index.php?action=--page zone.\$Service.map \$Service.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$FormTitle</title>]]></zone_title>
	<zone_window>zone-\$Service-detail</zone_window>
	<zone_type>button_form</zone_type>
	<zone_status>fault</zone_status>
	<zone_html><![CDATA[\$1]]></zone_html>\"
}
#-----------------
SERVICE_ON_BUZY ()
#-----------------
{
if [ ! -f $GoeActingFlag.\$Service.flag ] ; then
	Service0nBuzy=\"Available\"
else
	Service0nBuzy=\"Buzy\"
	FormTitle=\"\$T_Processing \$*...\"
	echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->
<zone name=\\\"zone.\$Service.${button_type}_form\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"$SiteRefreshResult; url=../index.php?action=--page zone.\$Service.map \$Service.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$FormTitle</title>]]></zone_title>
	<zone_window>zone-\$Service-detail</zone_window>
	<zone_type>button_form</zone_type>
	<zone_status>fault</zone_status>
	<zone_on_validate>--on_click zone.\$Service.${button_type}_form \$Service.${button_type}_result.template \$Service.${button_type}.template</zone_on_validate>
	<zone_form><![CDATA[\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service actingsignal\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Clear_acting_signal :  </td><td><input type=\\\"radio\\\" name=\\\"actingsignal\\\" value=\\\"wait\\\" checked> \$T_Acting_wait</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"actingsignal\\\" value=\\\"clear\\\" > \$T_Acting_clear</td></tr>
</table>
\$T_Warning : \$T_Superceed_acting_signal.<br/> ]]></zone_form>\"

fi
}
#-----------------
SERVICE_GET_LANGUAGE
#-----------------"
	FormServiceButtonDescription="SERVICE_GET_DESCRIPTION ()
#-----------------
{
#$ServiceButtonsFullList
Descriptions=\"
renew:	\$T_Renew_service \$Service
start:	\$T_Start_service \$Service
stop:	\$T_Stop_service \$Service
restart:	\$T_Restart_service \$Service
newcase:	\$T_Use_a_case \$Service
company:	\$T_Set_a_company \$Service
drop:	\$T_Drop_doc \$Service
newmooc:	\$T_New_Mooc_doc \$Service
managemooc:	\$T_Manage_Mooc_doc \$Service
exam:		\$T_Exam_doc \$Service
upload:	\$T_Upload_doc \$Service
installarchive:	\$T_Installarchive_doc \$Service
upgrade:	\$T_Upgrade_doc \$Service
downgrade:	\$T_Downgrade_doc \$Service
\"
button_name=\`echo \"\$Descriptions\" | grep \"^\$1:\" | cut -d: -f2-\`
}
#-----------------"
	FormGetReferences="SERVICE_GET_REFERENCES ()
#-----------------
{
case \"\$1\" in
--add)
	shift
	;;
*)
	optionarchive=\"\"
	optionlist=\"\"
	;;
esac
archivedir=\"\$1\"
if [ -d \"\$archivedir\" ] ; then
	ListArchives=\`ls \$archivedir | xargs\`
	echo \"<!--ListArchives \$ListArchives -->\"
	for archive in \$ListArchives ; do
		case \"\$archive\" in
		*.gz|*.dump|*.backup|*.script)
			optionarchive=\"\$optionarchive<option value=\\\"\$archivedir/\$archive\\\">\$archive</option>\"
			optionlist=\"\$optionlist \$archive\"
			;;
		esac
	done
fi
}
#-----------------
SERVICE_GET_PROFILES ()
#-------------------
{
archivedir=\"\$1\"
if [ -d \"\$archivedir\" ] ; then
	ListArchives=\`ls \$archivedir | xargs\`
	echo \"<!--ListArchives \$ListArchives -->\"
	for archive in \$ListArchives ; do
		case \"\$archive\" in
		*.script)
			optionarchive=\"\$optionarchive<option value=\\\"\$archivedir/\$archive\\\">\$archive</option>\"
			optionlist=\"\$optionlist \$archive\"
			;;
		esac
	done
fi
}
#-----------------"
	FormGetServiceData="
SERVICE_GET_SERVICE_DATA ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- > /tmp/goe.get_xoe_data.service.form.\$\$.sh
. /tmp/goe.get_xoe_data.service.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.service.form.\$\$.sh
erpname=\"\$ServiceErpName\"
serviceversion=\"\$ServiceVersion\"
}
#-----------------"
	FormGetCustoms="SERVICE_GET_CUSTOMS ()
#-----------------
{
customdir=\"\$1\"
if [ -d \"\$customdir\" ] ; then
	echo \"<!--ListCustoms \$ListCustoms -->\"
	OptionCustoms=\"\"
	ListCustoms=\"\"
	custom_content=\`ls \$customdir\`
	for custom_archive in \$custom_content ; do
		case \"\$custom_archive\" in
		*.tar.gz|*.zip)
			OptionCustoms=\"\$OptionCustoms<option value=\\\"\$customdir/\$custom_archive\\\">\$custom_archive</option>\"
			ListCustoms=\"\$ListCustoms \$custom_archive\"
			;;
		esac
	done
	IFS=\"\$standard_IFS\"
fi
}
#-----------------"
	FormGetGradability="
if [ ! -e \"$XoeDir/xoe.services/\$Service/upgraded.txt\" ] ; then
	Downgradability=\"unknown\"
else
	Downgradability=\"ok\"
fi
optionmodelversion=\"\"
optionlist=\"\"
if [ -e \"$XoeDir/xoe.services/\$Service/version/compatibility_\$Service.conf\" ] ; then
	ServiceCompatibilityList=\`cat $XoeDir/xoe.services/\$Service/version/compatibility_\$Service.conf\`
else
	ServiceCompatibilityList=\`/usr/local/bin/xoe --contract -compatible \$Service\`
fi
echo \"<!--ServiceCompatibilityList \$ServiceCompatibilityList -->\"
for modelversion in \$ServiceCompatibilityList ; do
		optionmodelversion=\"\$optionmodelversion<option value=\\\"\$modelversion\\\">\$modelversion</option>\"
		optionlist=\"\$optionlist \$modelversion\"
done
if [ -z \"\$ServiceCompatibilityList\" ] ; then
	Upgradability=\"unknown\"
#else
	#Upgradability=\"ok\"
fi
ServiceRole=\`/usr/local/bin/xoe --config -get -role \$Service | cut -f2\`
case \"\$ServiceRole\" in
production)
	Upgradability=\"protected\"
	;;
free*)
#	Upgradability=\"disallowed\"
	;;
esac"
	;;
#-------------
#Database Forms
#-------------
button_editdatabasemenu|button_restore|button_clone|button_copy|button_reference|button_delete|button_wipe_out|button_dbupdate)
	FormDbGenerics="
#-----------------
DATABASE_GET_LANGUAGE ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- | grep \"^ServiceLanguage=\"\ > /tmp/goe.get_xoe_data.language.form.\$\$.sh
. /tmp/goe.get_xoe_data.language.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.language.form.\$\$.sh
language=\"\$ServiceLanguage\"
if [ -z \"\$language\" ] ; then
	language=\"en\"
fi
. $GoeTranslationFile.\$language
if [ -e $GoeCustomTranslationFile.\$language ] ; then
	. $GoeCustomTranslationFile.\$language
fi
}
#-----------------
DATABASE_CAT ()
#-----------------
{
for ((idc=0;idc<50;idc=idc+1)) ; do
	if cat \$1 ; then
		break
	fi
	sleep 0.1
done
}
#-----------------
DATABASE_FORM_TOP_WINDOW ()
#-----------------
{
echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->\"
DATABASE_CAT $Drawings/\$Service.\$Database.menu.draw
}
#-----------------
DATABASE_FORM_GENERICS ()
#-----------------
{
echo \"
<zone name=\\\"zone.\$Service.\$Database.${button_type}_form\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"180; url=../index.php?action=--page zone.\$Service.\$Database.map \$Service.\$Database.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$1</title>]]></zone_title>
	<zone_type>button_form</zone_type>
	<zone_status>ok</zone_status>
	<zone_on_validate>--on_click zone.\$Service.\$Database.${button_type}_form \$Service.\$Database.${button_type}_result.template \$Service.\$Database.${button_type}.template</zone_on_validate>\"
}
#-----------------
DATABASE_FORM_BOTTOM ()
#-----------------
{
echo \"
<!-- end zone.\$Service.\$CommentDatabase.${button_type}_form --> </zone>
<!-- addendum form -->\"
DATABASE_CAT $Drawings/\$Service.\$Database.info.draw
}
#-----------------
DATABASE_ON_ERROR ()
#-----------------
{
echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->
<zone name=\\\"zone.\$Service.\$Database.${button_type}_form\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"$SiteRefreshResult; url=../index.php?action=--page zone.\$Service.\$Database.map \$Service.\$Database.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$FormTitle</title>]]></zone_title>
	<zone_type>button_form</zone_type>
	<zone_status>fault</zone_status>
	<zone_html><![CDATA[\$1]]></zone_html>\"
}
#-----------------
DATABASE_ON_BUZY ()
#-----------------
{
if [ ! -f $GoeActingFlag.\$Service.flag ] ; then
	Service0nBuzy=\"Available\"
else
	Service0nBuzy=\"Buzy\"
	FormTitle=\"\$T_Processing \$*...\"
	echo \"<!-- this template generated by $0 on $Date mode $ServerMode -->
<zone name=\\\"zone.\$Service.${button_type}_form\\\">
	<zone_refresh><![CDATA[<meta http-equiv=\\\"Refresh\\\" content=\\\"$SiteRefreshResult; url=../index.php?action=--page zone.\$Service.\$Database.map \$Service.\$Database.detail.draw\\\" />]]></zone_refresh>
	<zone_title><![CDATA[<title>\$FormTitle</title>]]></zone_title>
	<zone_window>zone-\$Service-detail</zone_window>
	<zone_type>button_form</zone_type>
	<zone_status>fault</zone_status>
	<zone_on_validate>--on_click zone.\$Service.\$Database.${button_type}_form \$Service.\$Database.${button_type}_result.template \$Service.\$Database.${button_type}.template</zone_on_validate>
	<zone_form><![CDATA[\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service actingsignal\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Clear_acting_signal :  </td><td><input type=\\\"radio\\\" name=\\\"actingsignal\\\" value=\\\"wait\\\" checked> \$T_Acting_wait</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"actingsignal\\\" value=\\\"clear\\\" > \$T_Acting_clear</td></tr>
</table>
\$T_Warning : \$T_Superceed_acting_signal.<br/> ]]></zone_form>\"

fi
}
#-----------------
DATABASE_GET_LANGUAGE
#-----------------"
	FormDatabaseButtonDescription="DATABASE_GET_DESCRIPTION ()
#-----------------
{
#$DatabaseButtonsFullList
#editdatabasemenu save restore clone copy reference delete wipe_out dbupdate
Descriptions=\"
save:	\$T_Save_database \$T_on_service \$Service
snapshot:	\$T_Snapshot_database  \$T_on_service \$Service
restore:	\$T_Restore_database \$T_on_service \$Service
clone:	\$T_Clone_database \$T_on_service \$Service \$T_to_several_copies
copy:	\$T_Copy_database \$T_on_service \$Service \$T_to_another_service
reference:	\$T_Reference_database \$T_on_service \$Service
delete:	\$T_Delete_database \$T_on_service \$Service
wipe_out:	\$T_Delete_archives_of_database \$T_on_service \$Service
dbupdate:	\$T_Update_database \$T_on_service \$Service
\"
button_name=\`echo \"\$Descriptions\" | grep \"^\$1:\" | cut -d: -f2-\`
}
#-----------------"
	FormGetErpName="DATABASE_GET_SERVICE_DATA ()
#-----------------
{
cat $XoeServicesData | grep \"^#Service:\$Service:\" | cut -f2- > /tmp/goe.get_xoe_data.database.form.\$\$.sh
. /tmp/goe.get_xoe_data.database.form.\$\$.sh
rm -f /tmp/goe.get_xoe_data.database.form.\$\$.sh
erpname=\"\$ServiceErpName\"
}
#-----------------"
	FormGetArchives="DATABASE_GET_ARCHIVES ()
#-----------------
{
archivedir=\"\$1\"
optionarchive=\"\"
optionlist=\"\"
if [ -d \"\$archivedir\" ] ; then
	ListArchives=\`ls \$archivedir | xargs\`
	echo \"<!-- ListArchives \$ListArchives -->\"
	for archive in \$ListArchives ; do
		case \"\$archive\" in
		daily*gz|last-*gz|monthly*gz|reference*gz|snapshot*gz|*gz|*dump|*backup|*script)
			optionarchive=\"\$optionarchive<option value=\\\"\$archivedir/\$archive\\\">\$archive</option>\"
			optionlist=\"\$optionlist \$archive\"
			;;
		esac
	done
fi
}
#-----------------"
	FormGetServiceList="DATABASE_GET_SERVICE_LIST ()
#-----------------
{
	optionservice=\"\"
	for copyservice in $ServiceList ; do
		case \"\$copyservice\" in
		\$Service)
			;;
		*)
			optionservice=\"\$optionservice<option value=\\\"\$copyservice\\\">\$copyservice</option>\"
			;;
		esac
	done

}
#-----------------"
	;;
esac
#TR T_of_database of databsae : de la base de donnees
#TR T_on_service on service: du service
#TR T_Warning WARNING : ATTENTION
case "$button_type" in
#
#----------------------- buttons related to services
#
#------------
#Service Forms
#------------
button_editservicemenu)
	#TR T_Service_menu	Manage menu options of service : Gerez les options de menu sur le service
	#TR T_Service_menu_form	Form to manage your menu options : Formulaire pour gerer vos options de menu
	#TR T_Service_menu_action	Compose service menu : Composez le menu du service
	#TR T_Lost_service_menu Adding functions may increase risk for mistakes : En ajoutant des fonctions, vous augmentez le risque d'erreur
	echo "#! /bin/bash
$FormServiceGenerics
$FormServiceButtonDescription
SERVICE_FORM_TOP_WINDOW
FormTitle=\"\$T_Service_menu \$Service\"
SERVICE_FORM_GENERICS \"\$FormTitle\"
available_menu_list=\`/usr/local/bin/xoe --config -get -panel \$Service | cut -f2- | cut -d+ -f1 | cut -d- -f1 | xargs\`
if [ -z \"\$available_menu_list\" ] ; then
	available_menu_list=\"$ServiceButtonsDefaultList\"
fi
enabled_menu_list=\`/usr/local/bin/xoe --config -get -panel \$Service | cut -f2- | cut -d+ -f2 | cut -d- -f1 | xargs\`
if [ -z \"\$enabled_menu_list\" ] ; then
	enabled_menu_list=\"$ServiceButtonsDefaultList\"
fi
echo \"
<zone_form><![CDATA[\$T_Service_menu_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service menu_name menu_content\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"menu_name\\\" value=\\\"-service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Service_menu_action : </td><td></td></tr>\"
for button in \$available_menu_list ; do
	case \"\$button\" in
	editservicemenu)
		;;
	*)
		SERVICE_GET_DESCRIPTION \$button
		case \"\$enabled_menu_list\" in
		*\$button*)
			echo \"<tr><td></td><td><input type=\\\"checkbox\\\" name=\\\"menu_content[]\\\" value=\\\"\$button\\\" checked> \$button_name</td></tr>\"
			;;
		*)
			echo \"<tr><td></td><td><input type=\\\"checkbox\\\" name=\\\"menu_content[]\\\" value=\\\"\$button\\\"> \$button_name</td></tr>\"
			;;
		esac
		;;
	esac
done
echo \"
 </table>    
\$T_Warning : \$T_Lost_service_menu<br/>
]]></zone_form>\"
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_newcase)
	#new case is related to a service, not a database
	#TR T_New_case_set	Creating a new database from a reference case on service : Creer une nouvelle base de donnees depuis un cas reference sur le service
	#TR T_New_case_form	Form to create a new database from a reference case : Formulaire pour creer une nouvelle base de donnees a partir d'un cas reference
	#TR T_Case_list	Compatible cases list : Liste des cas references compatibles
	#TR T_New_database	Name of new database : Nom de la nouvelle base de donnees creee
	#TR T_case_prefix	case_ : cas_
	#TR T_Choose_case	Choose case reference to be used : Choisissez la reference de cas a utiliser
	#TR T_Admin_password	Set administrator's password for the new database : Mot de passe de l'administrateur de la nouvelle base de donnees
	#TR T_Lost_content_new_case		if new database already exists, all current data will be lost definitively : le contenu actuel de la base de donnees creee, si elle existe deja, sera definitivement perdu
	#TR T_No_case	No case reference available to create a new database : Pas de donnees de reference disponibles pour creer une nouvelle base de donnees sur le service

	DefPassword=`NEW_PASSWORD 4 4`
	echo "#! /bin/bash
$FormServiceGenerics
$FormGetServiceData
$FormGetReferences
SERVICE_GET_SERVICE_DATA
SERVICE_FORM_TOP_WINDOW

SERVICE_ON_BUZY \$T_New_case
case \"\$Service0nBuzy\" in
Available)
	if [ -d \"$XoeDir/xoe.packages/database_models/\$erpname/\$serviceversion\" ] ; then
		SERVICE_GET_REFERENCES \"$XoeDir/xoe.packages/database_models/\$erpname/\$serviceversion\"
	fi
	if [ -d \"$XoeDir/xoe.packages/database_models/\$Service\" ] ; then
		SERVICE_GET_REFERENCES --add \"$XoeDir/xoe.packages/database_models/\$Service\"
	fi
	if [ ! -z \"\$optionarchive\" ] ; then
		FormTitle=\"\$T_New_case_set \$Service\"
		SERVICE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_New_case_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Case_list : \$optionlist<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database archive admin_password\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_New_database : </td><td><input type=text name=\\\"database\\\" value=\\\"\$T_case_prefix\$Service\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Choose_case : </td><td><select name=\\\"archive\\\" $InputStyle >\$optionarchive</select></td></tr>
<tr><td>\$T_Admin_password : </td><td><input type=text name=\\\"admin_password\\\" value=\\\"admin_${DefPassword}\\\" $InputStyle required ></td></tr>
</table>
\$T_Warning : \$T_Lost_content_new_case.<br/>
</p>]]></zone_form>\"
	else
		FormTitle=\"\$T_No_case \$Service erp \$erpname version \$serviceversion\"
		SERVICE_ON_ERROR \"\$FormTitle\"
	fi
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_company)
	#new company is related to a service, not a database
	#TR T_Company_set	Creating a company profile on service : Creer un profil de societe sur le service
	#TR T_Company_form	Form to create a company profile : Formulaire pour creer un profil de societe
	#TR T_Profil_list	Existing profils : Profils existants
	#TR T_Company_name	Company name : Nom de la societe
	#TR T_Choose_month	First day of fiscal year : Debut de l exercice
	#TR T_Choose_period	Accounting periods : Periodes de comptabilite
	#TR T_default_company	My Company : Ma Societe

	#TR T_Lost_content_company	populate a database from a profil is very long, up to 20mn. Consider restoring a reference database instead if available: peupler une base de donnees a partir d un profile est tres long. jusqu a 20mn. Preferez la restauration d une reference si elle est disponible
	#TR T_No_company	Company profile is not available with Odoo on service : Les profils de societe ne sont pas supportes avec Odoo sur le service
	#TR T_january	January 1st : 1er janvier
	#TR T_february	February 1st : 1er fevrier
	#TR T_march	March 1st : 1er mars
	#TR T_april	April 1st : 1er avril
	#TR T_may	May 1st : 1er mai
	#TR T_june	June 1st : 1er juin
	#TR T_july	July 1st : 1er juillet
	#TR T_august	August 1st : 1er aout
	#TR T_september	September 1st : 1er septembre
	#TR T_october	October 1st : 1er octobre
	#TR T_november	November 1st : 1er novembre
	#TR T_december	December 1st : 1er decembre
	#TR T_monthly	Month : Mois
	#TR T_quarterly	Quarter : Trimestre
	DefPassword=`NEW_PASSWORD 4 4`
	echo "#! /bin/bash
$FormServiceGenerics
$FormGetServiceData
$FormGetReferences
SERVICE_GET_SERVICE_DATA

if [ -d \"$XoeDir/xoe.packages/database_models/\$Service\" ] ; then
	SERVICE_GET_PROFILES \"$XoeDir/xoe.packages/database_models/\$Service\"
fi
optionmonth=\"<option value=\\\"1\\\">\$T_january</option>
<option value=\\\"2\\\">\$T_february</option>
<option value=\\\"3\\\">\$T_march</option>
<option value=\\\"4\\\">\$T_april</option>
<option value=\\\"5\\\">\$T_may</option>
<option value=\\\"6\\\">\$T_june</option>
<option value=\\\"7\\\">\$T_july</option>
<option value=\\\"8\\\">\$T_august</option>
<option value=\\\"9\\\">\$T_september</option>
<option value=\\\"10\\\">\$T_october</option>
<option value=\\\"11\\\">\$T_november</option>
<option value=\\\"12\\\">\$T_december</option>\"
SERVICE_FORM_TOP_WINDOW
case \"\$erpname\" in
tryton)
	FormTitle=\"\$T_Company_set \$Service\"
	SERVICE_FORM_GENERICS \"\$FormTitle\"
	echo \"
	<zone_form><![CDATA[<p>\$T_Company_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Profil_list : \$optionlist<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service month period company\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Company_name : </td><td><input type=\\\"text\\\" name=\\\"company\\\" value=\\\"\$T_default_company\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Choose_month : </td><td><select name=\\\"month\\\" $InputStyle required>\$optionmonth</select></td></tr>
<tr><td>\$T_Choose_period :  </td><td><input type=\\\"radio\\\" name=\\\"period\\\" value=\\\"1\\\" checked> \$T_monthly</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"period\\\" value=\\\"3\\\" > \$T_quarterly</td></tr>
</table>
\$T_Warning : \$T_Lost_content_company.<br/>
</p>]]></zone_form>\"
	;;
*)
	FormTitle=\"\$T_No_company \$Service version \$serviceversion\"
	SERVICE_ON_ERROR \"\$FormTitle\"
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_drop)
	#drop is related to a service, not a database
	#TR T_Drop_set	Drop a set of databases on service : Supprimer un ensemble de bases de donnees sur le service
	#TR T_Drop_form	Form to drop a set of databases whose names begin by a list of prefixes : Formulaire pour supprimer un ensemble de bases de donnees dont les noms commencent par l un des prefixes d'une liste
	#TR T_Prefix_drop	Specify prefixes of databases names to be dropped : Specifiez les prefixes des noms des bases de donnees a supprimer
	#TR T_Lost_content_drop		All data of all databases whose name begin by one of these prefixes of the list will be lost definitively : tous les contenus de toutes les bases de donnees dont le nom commence par l un des prefixes de la liste seront definitivement perdus
	echo "#! /bin/bash
$FormServiceGenerics
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Drop
case \"\$Service0nBuzy\" in
Available)
	FormTitle=\"\$T_Drop_set \$Service\"
	SERVICE_FORM_GENERICS \"\$FormTitle\"
	echo \"
	<zone_form><![CDATA[<p>\$T_Drop_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service dropprefix\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Prefix_drop : </td><td><input type=text name=\\\"dropprefix\\\" value=\\\"clone copy copie case\\\" $InputStyle required ></td></tr>
</table>
\$T_Warning : \$T_Lost_content_drop.<br/>
</p>]]></zone_form>\"
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_newmooc)
	#new mooc is related to a service, not a database
	#TR T_New_mooc_set	Creating a new course from a reference case on service : Creer un nouveau cours depuis un cas reference sur le service
	#TR T_New_mooc_form	Form to create a new course from a reference case : Formulaire pour creer un nouveau cours a partir d'un cas reference
	#TR T_Case_list Compatible cases list : Liste des cas references compatibles
	#TR T_New_mooc	Name of new course : Nom du nouveau cours cree
	#TR T_mooc_prefix	course_ : cours_
	#TR T_Choose_case	Choose case reference to be used : Choisissez la reference de cas a utiliser
	#TR T_Mooc_Min	Initial training databases creation : Nombre de bases de donnees initialement crees
	#TR T_Mooc_Max	Max training databases capacity : Nombre maximal de bases de donnees des eleves
	#TR T_Mooc_Mail	Teacher's mail address : Adresse mail du maitre
	#TR T_No_reference	No case reference available to create a new course : Pas de donnees de reference disponibles pour creer un nouveau cours sur le service
	echo "#! /bin/bash
$FormServiceGenerics
$FormGetServiceData
$FormGetReferences
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Mooc
case \"\$Service0nBuzy\" in
Available)
	SERVICE_GET_SERVICE_DATA
	if [ -d \"$XoeDir/xoe.packages/database_models/\$erpname/\$serviceversion\" ] ; then
		SERVICE_GET_REFERENCES \"$XoeDir/xoe.packages/database_models/\$erpname/\$serviceversion\"
	fi
	if [ -d \"$XoeDir/xoe.packages/database_models/\$Service\" ] ; then
		SERVICE_GET_REFERENCES --add \"$XoeDir/xoe.packages/database_models/\$Service\"
	fi
	if [ ! -z \"\$optionarchive\" ] ; then
		FormTitle=\"\$T_New_mooc_set \$Service\"
		SERVICE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_New_mooc_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Case_list : \$optionlist<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service mooc_name archive mooc_min mooc_max mooc_mail\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_New_mooc : </td><td><input type=text name=\\\"mooc_name\\\" value=\\\"\$T_mooc_prefix\$Service\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Choose_case : </td><td><select name=\\\"archive\\\" $InputStyle >\$optionarchive</select></td></tr>
<tr><td>\$T_Mooc_Min :</td><td> <input type=text name=\\\"mooc_min\\\" value=\\\"0\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Mooc_Max :</td><td> <input type=text name=\\\"mooc_max\\\" value=\\\"30\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Mooc_Mail : </td><td><input type=email name=\\\"mooc_mail\\\" $InputStyle required ></td></tr>
</table>
</p>]]></zone_form>\"
	else
		FormTitle=\"\$T_No_reference \$Service erp \$erpname version \$serviceversion\"
		SERVICE_ON_ERROR \"\$FormTitle\"
	fi
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_managemooc)
	#drop is related to a service, not a database
	#TR T_Mooc_mgt	Manage your course on service : Gerez votre cours sur le service
	#TR T_Mooc_mgt_form	Form to manage your courses Open registration, Close registration, Cancel course : Formulaire pour gerer vos cours Ouvrir les inscriptions, Cloturer les inscriptions, Supprimer le cours
	#TR T_Mooc_to_manage	Course name : Nom du cours
	#TR T_Mooc_report	Report and instructions : Rapport et instructions
	#TR T_Mooc_open		Open registration : Ouvrir les inscriptions
	#TR T_Mooc_close	Close registration : Fermer les inscriptions
	#TR T_Mooc_cancel	Cancel course : Supprimer le cours
	#TR T_Mooc_action	Action open,close,cancel : Action ouvrir,fermer,supprimer
	#TR T_Lost_content_mooc Only Open courses are allowed for students registrations : Les etudiants ne peuvent s'incrire que sur les cours Ouverts
	#TR T_Mooc_hide	Hide database names on service : Masquer les noms de bases de donnees du service
	#TR T_Mooc_show	Show database names on service : Afficher les noms des bases de donnees du service
	echo "#! /bin/bash
$FormServiceGenerics
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Managemooc
case \"\$Service0nBuzy\" in
Available)
	FormTitle=\"\$T_Mooc_mgt \$Service\"
	SERVICE_FORM_GENERICS \"\$FormTitle\"
	moocservicelist=\`/usr/local/bin/mooc --list \$Service\`
	moocoptionlist=\"\"
	for moocelement in \$moocservicelist ; do 
		moocoptionlist=\"\$moocoptionlist <option value=\\\"\$moocelement\\\">\$moocelement</option>\"
	done
	echo \"
<zone_form><![CDATA[<p>\$T_Mooc_mgt_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service mooc_name mooc_action\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Mooc_to_manage : </td><td><select name=\\\"mooc_name\\\" $InputStyle required >\$moocoptionlist</select></td></tr>
<tr><td>\$T_Mooc_action : </td><td><input type=\\\"radio\\\" name=\\\"mooc_action\\\" value=\\\"--spool_report\\\" checked> \$T_Mooc_report</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"mooc_action\\\" value=\\\"--open\\\" > \$T_Mooc_open</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"mooc_action\\\" value=\\\"--close\\\" > \$T_Mooc_close</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"mooc_action\\\" value=\\\"--hide_database\\\" > \$T_Mooc_hide \$Service</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"mooc_action\\\" value=\\\"--show_database\\\" > \$T_Mooc_show \$Service</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"mooc_action\\\" value=\\\"--cancel\\\" > \$T_Mooc_cancel</td></tr>
</table>
\$T_Warning : \$T_Lost_content_mooc.<br/>
</p>]]></zone_form>\"
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_exam)
	#
	#TR T_Exam_title	Manage your exam session on service : Gerez votre session d examen sur le service
	#TR T_Exam_form	Form to manage logins and password during exam sessin : Formulaire pour gerer les identifiants et mots de passe pendant une session d examen
	#TR T_Exam_to_manage	Course name : Nom du cours
	#TR T_Exam_login	Patched Login : Login modifie
	#TR T_Exam_password	Patched password : Mot de passe modifie
	#TR T_Exam_action	patch or restore ids : Modifier ou retablir les identifiants
	#TR T_Exam_patch	Patch ids as follows : Modifier les identifiants avec les valeurs suivantes
	#TR T_Exam_restore	Restore original ids : Retablir les identifiants d origine
	#TR T_Lost_content_exam Ids are modified in all databases declared in that course : Les identifiants sont modifies pour toutes les bases de donnees de ce cours
	DefPassword=`NEW_PASSWORD 4 4`
	echo "#! /bin/bash
$FormServiceGenerics
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Exam
case \"\$Service0nBuzy\" in
Available)
	FormTitle=\"\$T_Exam_title \$Service\"
	SERVICE_FORM_GENERICS \"\$FormTitle\"
	moocservicelist=\`/usr/local/bin/mooc --list \$Service\`
	moocoptionlist=\"\"
	for moocelement in \$moocservicelist ; do 
		moocoptionlist=\"\$moocoptionlist <option value=\\\"\$moocelement\\\">\$moocelement</option>\"
	done
	echo \"
	<zone_form><![CDATA[<p>\$T_Exam_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service mooc_name exam_action exam_login exam_password\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Exam_to_manage : </td><td><select name=\\\"mooc_name\\\" $InputStyle required >\$moocoptionlist</select></td></tr>
<tr><td>\$T_Exam_action : </td><td><input type=\\\"radio\\\" name=\\\"exam_action\\\" value=\\\"--spool_restore_logins\\\" > \$T_Exam_restore</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"exam_action\\\" value=\\\"--spool_replace_logins\\\" checked> \$T_Exam_patch</td></tr>
<tr><td>\$T_Exam_login : </td><td><input type=text name=\\\"exam_login\\\" value=\\\"admin\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Exam_password : </td><td><input type=text name=\\\"exam_password\\\" value=\\\"admin_${DefPassword}\\\" $InputStyle required ></td></tr>
</table>
\$T_Warning : \$T_Lost_content_exam.<br/>
</p>]]></zone_form>\"
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_upload)
	#TR T_Uploading	Add a archive to service : Ajout d une archive au service
	#TR T_Upload_form	Form to upload a new archive to the service : Formulaire pour telecharger une nouvelle archive au service
	#TR T_No_upload	Adding a new archive to service : L ajout d une archive au service
	#TR T_upload_is_protected	is dangerous. This service should be protected for its production role : est risque. Ce service doit etre protege pour son role en production
	#TR T_upload_is_disallowed	is not permitted : n'est pas autorisee
	#TR T_upload_cannot_be_modified	cannot be uploaded : ne peut pas etre telecharge
	#TR T_Upload_installed_	New archive installed : Nouvelle installation
	#TR T_Lost_content_upload	Only install compatible archives under AGPL, GPL or LGPL. Your service may stop for technical problems or legal reasons. Data may be lost. : N'installez que des archives compatibles sous licence AGPL, GPL ou LGPL. Votre service peut se bloquer pour une cause technique ou etre arrete pour une raison legale. Les donnees risquent d etre perdues.
	#TR T_Upload_validate	Validate this form to move these archives to your service : Validez pour deplacer ces archives vers le service
	#TR T_Upload_after_validate	Then you can install or remove uploaded archives with Archives... button. : Ensuite vous pourrez installer ou supprimer les archives telechargees avec le bouton Archives...
	echo "#! /bin/bash
$FormServiceGenerics
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Upload
case \"\$Service0nBuzy\" in
Available)

	case \"\$Uploadability\" in
	ok|protected)
		uploader=\"<script type=\\\"text/javascript\\\">
// common variables
var iBytesUploaded = 0;
var iBytesTotal = 0;
var iPreviousBytesLoaded = 0;
var iMaxFilesize = $MaxArchiveUploadSize;
var oTimer = 0;
var sResultFileSize = '';

function secondsToTime(secs) { // we will use this function to convert seconds in normal time format
    var hr = Math.floor(secs / 3600);
    var min = Math.floor((secs - (hr * 3600))/60);
    var sec = Math.floor(secs - (hr * 3600) -  (min * 60));

    if (hr < 10) {hr = \\\"0\\\" + hr; }
    if (min < 10) {min = \\\"0\\\" + min;}
    if (sec < 10) {sec = \\\"0\\\" + sec;}
    if (hr) {hr = \\\"00\\\";}
    return hr + ':' + min + ':' + sec;
};

function bytesToSize(bytes) {
    var sizes = ['Bytes', 'KB', 'MB'];
    if (bytes == 0) return 'n/a';
    var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
    return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};

function fileSelected() {

    // hide different warnings
    document.getElementById('upload_response').style.display = 'none';
    document.getElementById('errorextension').style.display = 'none';
    document.getElementById('errortransfer').style.display = 'none';
    document.getElementById('abort').style.display = 'none';
    document.getElementById('warnsize').style.display = 'none';

    // get selected file element
    var oFile = document.getElementById('archive_upload').files[0];

    // filter for image files
    var rFilter = /^(application\\\/tar.gz|application\\\/zip)$/i;
    if (! rFilter.test(oFile.type)) {
        document.getElementById('errorextension').style.display = 'block';
        return;
    }

    // little test for filesize
    if (oFile.size > iMaxFilesize) {
        document.getElementById('warnsize').style.display = 'block';
        return;
    }
}

function startUploading() {
    // cleanup all temp states
    iPreviousBytesLoaded = 0;
    document.getElementById('upload_response').style.display = 'none';
    document.getElementById('errorextension').style.display = 'none';
    document.getElementById('errortransfer').style.display = 'none';
    document.getElementById('abort').style.display = 'none';
    document.getElementById('warnsize').style.display = 'none';
    document.getElementById('progress_percent').innerHTML = '';
    var oProgress = document.getElementById('progress');
    oProgress.style.display = 'block';
    oProgress.style.width = '0px';

    // get form data for POSTing
    //var vFD = document.getElementById('upload_form').getFormData(); // for FF3
    var vFD = new FormData(document.getElementById('upload_form')); 

    // create XMLHttpRequest object, adding few event listeners, and POSTing our data
    var oXHR = new XMLHttpRequest();        
    oXHR.upload.addEventListener('progress', uploadProgress, false);
    oXHR.addEventListener('load', uploadFinish, false);
    oXHR.addEventListener('errorextension', uploadError, false);
    oXHR.addEventListener('abort', uploadAbort, false);
    oXHR.open('POST', 'upload.php');
    oXHR.send(vFD);

    // set inner timer
    oTimer = setInterval(doInnerUpdates, 300);
}

function doInnerUpdates() { // we will use this function to display upload speed
    var iCB = iBytesUploaded;
    var iDiff = iCB - iPreviousBytesLoaded;

    // if nothing new loaded - exit
    if (iDiff == 0)
        return;

    iPreviousBytesLoaded = iCB;
    iDiff = iDiff * 2;
    var iBytesRem = iBytesTotal - iPreviousBytesLoaded;
    var secondsRemaining = iBytesRem / iDiff;

    // update speed info
    var iSpeed = iDiff.toString() + 'B/s';
    if (iDiff > 1024 * 1024) {
        iSpeed = (Math.round(iDiff * 100/(1024*1024))/100).toString() + 'MB/s';
    } else if (iDiff > 1024) {
        iSpeed =  (Math.round(iDiff * 100/1024)/100).toString() + 'KB/s';
    }

    document.getElementById('speed').innerHTML = iSpeed;
    document.getElementById('remaining').innerHTML = '| ' + secondsToTime(secondsRemaining);        
}

function uploadProgress(e) { // upload process in progress
    if (e.lengthComputable) {
        iBytesUploaded = e.loaded;
        iBytesTotal = e.total;
        var iPercentComplete = Math.round(e.loaded * 100 / e.total);
        var iBytesTransfered = bytesToSize(iBytesUploaded);

        document.getElementById('progress_percent').innerHTML = iPercentComplete.toString() + '%';
        document.getElementById('progress').style.width = (iPercentComplete * 5).toString() + 'px';
        document.getElementById('b_transfered').innerHTML = iBytesTransfered;
        if (iPercentComplete == 100) {
            var oUploadResponse = document.getElementById('upload_response');
            oUploadResponse.innerHTML = '<p>Please wait...processing</p>';
            oUploadResponse.style.display = 'block';
        }
    } else {
        document.getElementById('progress').innerHTML = 'unable to compute';
    }
}

function uploadFinish(e) { // upload successfully finished
    var oUploadResponse = document.getElementById('upload_response');
    oUploadResponse.innerHTML = e.target.responseText;
    oUploadResponse.style.display = 'block';

    document.getElementById('progress_percent').innerHTML = '100%';
    document.getElementById('progress').style.width = '500px';
    document.getElementById('filesize').innerHTML = sResultFileSize;
    document.getElementById('remaining').innerHTML = '| 00:00:00';

    clearInterval(oTimer);
}

function uploadError(e) { // upload error
    document.getElementById('errortransfer').style.display = 'block';
    clearInterval(oTimer);
}  

function uploadAbort(e) { // upload abort
    document.getElementById('abort').style.display = 'block';
    clearInterval(oTimer);
}
  </script> 
<div class=\\\"container\\\">
	<div class=\\\"upload_form_cont\\\">
		<form id=\\\"upload_form\\\" enctype=\\\"multipart/form-data\\\" method=\\\"post\\\" action=\\\"upload.php\\\">
		<div>
			<div><label for=\\\"archive_upload\\\">Telecharger l'archive de chaque archive au format .tar.gz ou .zip. Upload a .tar.gz or .zip archive for each archive.</label></div>
			<br/>
			<div>
				<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service archive_upload\\\">
				<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
				<input type=\\\"file\\\" name=\\\"archive_upload\\\" id=\\\"archive_upload\\\" accept=\\\".tar.gz, .zip\\\" onchange=\\\"fileSelected();\\\" />
			</div>
		</div>
		<br/>
		<div>
			<input type=\\\"button\\\" value=\\\"upload\\\" onclick=\\\"startUploading()\\\" />
		</div>
		<div id=\\\"errorextension\\\">Select an archive .tar.gz or .zip</div>
		<div id=\\\"errortransfer\\\">An error occurred while uploading the file</div>
		<div id=\\\"abort\\\">The upload has been canceled by the user or the browser dropped the connection</div>
		<div id=\\\"warnsize\\\">File is too big. It will be rejected.</div>
		<div id=\\\"progress_info\\\">
			<div id=\\\"progress\\\"></div>
			<div id=\\\"progress_percent\\\">&nbsp;</div>
			<div class=\\\"clear_both\\\"></div>
			<div>
				<div id=\\\"speed\\\">&nbsp;</div>
				<div id=\\\"remaining\\\">&nbsp;</div>
				<div id=\\\"b_transfered\\\">&nbsp;</div>
				<div class=\\\"clear_both\\\"></div>
			</div>
			<div id=\\\"upload_response\\\"></div>
		</div>
		</form>
	</div>
</div>
\"
		case \"\$Uploadability\" in
		ok)
			FormTitle=\"\$T_Uploading \$Service\"
			;;
		protected)
			FormTitle=\"\$T_No_upload \$Service \$T_upload_is_protected \"
			;;
		esac
		SERVICE_FORM_GENERICS \"\$FormTitle\"

		echo \"<!-- this template generated by $0 on $Date mode $ServerMode, uploadability is \$Uploadability-->
<!-- upload archives form -->
<zone_html><![CDATA[\$T_Upload_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<br/><hr/><br/><br/>
\$uploader]]></zone_html>
<!-- validatation form -->
<zone_form><![CDATA[
<br/><hr/><br/>
<br/>\$T_Upload_validate \$Service<br/>
\$T_Upload_after_validate<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
\$T_Warning : \$T_Lost_content_upload.<br/>
<br/>]]></zone_form>\"
		;;
	disallowed)
		FormTitle=\"\$T_No_upload \$Service \$T_upload_is_disallowed, uploadability is \$Uploadability \"
		SERVICE_ON_ERROR \"\$FormTitle\"
		;;
	*)
		FormTitle=\"\$T_No_upload \$Service \$T_upload_cannot_be_modified  uploadability is \$Uploadability\"
		SERVICE_ON_ERROR \"\$FormTitle\"
		;;
	esac
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_installarchive)
	#drop is related to a service, not a database
	#TR T_Archive_mgt	Manage your custom archives on service : Gerez vos archives specifiques sur le service
	#TR T_Archive_mgt_form	Form to manage your archives Install or remove archive : Formulaire pour gerer vos archives Installer ou Supprimer l archive
	#TR T_Archive_list	Uploaded archives list : Liste des archives telechargees
	#TR T_Archive_to_manage	Archive name : Nom de l archive
	#TR T_Archive_install	Install archive to service (no way back) : Installer l archive sur le service (irreversible)
	#TR T_Archive_remove	Remove archive from specific library : Supprimer l archive de la bibliotheque specifique
	#TR T_Archive_action	Action install, delete : Action effacer ou installer
	#TR T_Lost_content_archive	Only tested archive can preserve your data : N utilisez que des archives testees
	#TR T_Install_failure	No custom archive to install on service : Pas d archive specifique installable sur le service
	echo "#! /bin/bash
$FormServiceGenerics
$FormGetCustoms
SERVICE_GET_CUSTOMS  \"$XoeDir/xoe.services/\$Service/custom\"
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_installarchive
case \"\$Service0nBuzy\" in
Available)
	if [ ! -z \"\$ListCustoms\" ] ; then
		FormTitle=\"\$T_Archive_mgt \$Service\"
		SERVICE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_Archive_mgt_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Archive_list : \$ListCustoms<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service archive_name archive_action\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Archive_to_manage : </td><td><select name=\\\"archive_name\\\" $InputStyle required >\$OptionCustoms</select></td></tr>
<tr><td>\$T_Archive_action</td><td><input type=\\\"radio\\\" name=\\\"archive_action\\\" value=\\\"--remove\\\" checked > \$T_Archive_remove</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"archive_action\\\" value=\\\"--directory\\\" > \$T_Archive_install</td></tr>
</table>
\$T_Warning : \$T_Lost_content_archive.<br/>
</p>]]></zone_form>\"
	else
		FormTitle=\"\$T_Install_failure  \$Service\"
		SERVICE_ON_ERROR \"\$FormTitle\"
	fi
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_upgrade)
	#TR T_Upgrading	Change	version of service : Changement de version du service
	#TR T_Upgrade_form	Form to install a new version of the service : Formulaire pour installer une nouvelle version du service
	#TR T_No_upgrade	Reinstallation of service : La reinstallation du service
	#TR T_is_protected	is dangerous. This service should be protected for its production role : est risquee. Ce service doit etre protege pour son role en production
	#TR T_is_disallowed	is not permitted : n'est pas autorisee
	#TR T_cannot_be_modified	cannot be modified : ne peut pas etre modifiee
	#TR T_Modelversion	New version installed : Version de la nouvelle installation
	#TR T_Lost_content_upgrade		Odoo/OpenERP only supports minor release updates, Tryton supports some version upgrade. New version must be more recent : Odoo/OpenERP ne supporte que les changements de revision mineurs, Tryton supporte les montees de version mais des operations specifiques peuvent etre necessaires. La nouvelle version doit etre posterieure
	echo "#! /bin/bash
$FormServiceGenerics
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Upgrade
case \"\$Service0nBuzy\" in
Available)
	$FormGetGradability
	case \"\$Upgradability\" in
	ok)
		FormTitle=\"\$T_Upgrading \$Service\"
		SERVICE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_Upgrade_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
Liste \$ServiceCompatibilityList<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service modelversion\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Modelversion : </td><td><select name=\\\"modelversion\\\" $InputStyle >\$optionmodelversion</select></td></tr>
</table>
\$T_Warning : \$T_Lost_content_upgrade.<br/>
</p>]]></zone_form>\"
		;;
	protected)
		FormTitle=\"\$T_No_upgrade \$Service \$T_is_protected \"
		SERVICE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_Upgrade_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
Liste \$ServiceCompatibilityList<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service modelversion\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Modelversion : </td><td><select name=\\\"modelversion\\\" $InputStyle >\$optionmodelversion</select></td></tr>
</table>
\$T_Warning : \$T_Lost_content_upgrade.<br/>
</p>]]></zone_form>\"
		;;
	disallowed)
		FormTitle=\"\$T_No_upgrade \$Service \$T_is_disallowed \"
		SERVICE_ON_ERROR \"\$FormTitle\"
		;;
	*)
		FormTitle=\"\$T_No_upgrade \$Service \$T_cannot_be_modified\"
		SERVICE_ON_ERROR \"\$FormTitle\"
		;;
	esac
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_downgrade)
	#TR T_Downgrading	Reverse last version upgrade of service : Retour a la version precedente du service
	#TR T_Downgrade_form Form to reverse last version upgrade of service : Formulaire pour revenir a la version precedente du service
	#TR T_No_downgrade version of service : La version du service
	#TR T_not_upgraded was not upgraded : n'a pas ete modifiee
	#TR T_Lost_content_downgrade		database contents will be reset to the level before upgrade : les contenus des bases de donnees vont etre reinitialises a ce qu ils etaient avant la montee de version.
	echo "#! /bin/bash
$FormServiceGenerics
SERVICE_FORM_TOP_WINDOW
SERVICE_ON_BUZY \$T_Downgrade
case \"\$Service0nBuzy\" in
Available)
	$FormGetGradability
	case \"\$Downgradability\" in
	ok)
		FormTitle=\"\$T_Downgrading \$Service\"
		SERVICE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_Downgrade_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
\$T_Warning : \$T_Lost_content_downgrade.<br/>
</p>]]></zone_form>\"
		;;
	*)
		FormTitle=\"\$T_No_downgrade \$Service \$T_not_upgraded\"
		SERVICE_ON_ERROR \"\$FormTitle\"
		;;
	esac
	;;
esac
SERVICE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
#-------------
#Database Menu
#-------------
button_editdatabasemenu)
	#TR T_Database_menu	Manage database operational menu of service : Gerer le menu operationnel des bases de donnees du service
	#TR T_Database_menu_form	Form to manage database operationnal menu : Formulaire pour gerer le menu operationnel des bases de donnees
	#TR T_Database_menu_action	Compose database menu for service : Composez le menu des bases de donnees du service
	#TR T_Database_menu_general	Modifications will apply to all databases of service : Les modifications sont appliquees a toutes les bases du service
	#TR T_Lost_database_menu Adding functions may increase risk for mistakes : En ajoutant des fonctions, vous augmentez le risque d'erreur
	echo "#! /bin/bash
$FormDbGenerics
$FormDatabaseButtonDescription
DATABASE_FORM_TOP_WINDOW
FormTitle=\"\$T_Database_menu \$Service\"
DATABASE_FORM_GENERICS \"\$FormTitle\"
available_menu_list=\`/usr/local/bin/xoe --config -get -panel \$Service | cut -f2- | cut -d+ -f1 | cut -d- -f2 | xargs\`
if [ -z \"\$available_menu_list\" ] ; then
	available_menu_list=\"$DatabaseButtonsDefaultList\"
fi
enabled_menu_list=\`/usr/local/bin/xoe --config -get -panel \$Service | cut -f2- | cut -d+ -f2 | cut -d- -f2 | xargs\`
if [ -z \"\$enabled_menu_list\" ] ; then
	enabled_menu_list=\"$DatabaseButtonsDefaultList\"
fi
echo \"
<zone_form><![CDATA[<p>\$T_Database_menu_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service menu_name menu_content\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"menu_name\\\" value=\\\"-database\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Database_menu_action : </td><td></td></tr>\"
for button in \$available_menu_list ; do
	case \"\$button\" in
	editdatabasemenu)
		;;
	*)
		DATABASE_GET_DESCRIPTION \$button
		case \"\$enabled_menu_list\" in
		*\$button*)
			echo \"<tr><td></td><td><input type=\\\"checkbox\\\" name=\\\"menu_content[]\\\" value=\\\"\$button\\\" checked> \$button_name</td></tr>\"
			;;
		*)
			echo \"<tr><td></td><td><input type=\\\"checkbox\\\" name=\\\"menu_content[]\\\" value=\\\"\$button\\\"> \$button_name</td></tr>\"
			;;
		esac
		;;
	esac
done
echo \"
 </table>    
\$T_Warning : \$T_Database_menu_general \$Service. \$T_Lost_database_menu<br/>
</p>]]></zone_form>\"
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_restore)
	#TR T_Restoring_an_archive	Restoring an archive : Restaurer une sauvegarde
	#TR T_Restoring_form Form for database restoration : Formulaire de restauration de base de donnees
	#TR T_Liste_of_archives		Liste of archives : Liste des sauvegardes compatibles
	#TR T_Name_of_restored_database	Give a name to the restored database : Donnez un nom a la base de donnees restauree
	#TR T_Database_archive		Choose database archive to be restored : Choisissez les donnees sauvegardees a restaurer

	#TR T_Lost_content_restore	if restored database already exists, all current data will be lost definitively : le contenu actuel de la base de donnees restauree, si elle existe deja, sera definitivement perdu
	#TR T_Restoring_failure		Failure while restoring database : Anomalie lors de la restauration de la base de donnees

	#TR T_No_archive		No valid archive for database : Pas de sauvegarde valide pour la base de donnees
	#TR T_to_be_restored		to be restored on service : a restaurer pour le service
	DatabaseKey=`NEW_PASSWORD -min 4 4`
	echo "#! /bin/bash
$FormDbGenerics
$FormGetArchives
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_Restore
case \"\$Service0nBuzy\" in
Available)
	DATABASE_GET_ARCHIVES \"$XoeDir/xoe.services/\$Service/database/\$Database\"
	if [ ! -z \"\$optionarchive\" ] ; then
		FormTitle=\"\$T_Restoring_an_archive \$T_of_database \$Database \$T_on_service \$Service\"
		DATABASE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_Restoring_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Liste_of_archives : \$optionlist<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database archive\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<br/><hr/><br/>
<table>
<tr><td>\$T_Name_of_restored_database : </td><td><input type=text name=\\\"database\\\" value=\\\"\${Database}_$DatabaseKey\\\" $InputStyle required ></td></tr>
<tr><td>\$T_Database_archive : </td><td><select name=\\\"archive\\\" $InputStyle >\$optionarchive</select></td></tr>
</table>
\$T_Warning : \$T_Lost_content_restore.<br/>
</p>]]></zone_form>\"
	else
		FormTitle=\"\$T_Restoring_failure \$Database \$T_on_service \$Service\"
		DATABASE_ON_ERROR \"\$T_No_archive \$Database \$T_to_be_restored \$Service\"
	fi
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_clone)
	#TR T_Cloning_database Cloning database : Cloner la base de donnees
	#TR T_Cloning_form Form for database cloning to several copies on the same service : Formulaire de clonage de la base de donnees en plusieurs exemplaires sur le meme service
	#TR T_Prefixes Choose prefixes added to the name of cloned database : Choisissez les prefixes ajoutes au nom de la base de donnees clonee
	#TR T_Lost_contents_clone if created databases already exist, all current data will be lost definitively : le contenu actuel des bases de donnees creees, si elles existent deja, sera definitivement perdu
	#TR T_Cloning failure Failure while cloning database : Anomalie lors du clonage de la base de donnees
	#TR T_No_archive No valid archive for database : Pas de sauvegarde valide pour la base de donnees
	#TR T_save_first first save database to be cloned : vous devez d abord sauvegarder la base de donnees a cloner
	echo "#! /bin/bash
$FormDbGenerics
$FormGetArchives
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_Clone
case \"\$Service0nBuzy\" in
Available)
	DATABASE_GET_ARCHIVES \"$XoeDir/xoe.services/\$Service/database/\$Database\"
	if [ ! -z \"\$optionarchive\" ] ; then
		FormTitle=\"\$T_Cloning_database \$Database \$T_on_service \$Service\"
		DATABASE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_Cloning_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Database : \$Database<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database cloneprefix\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"database\\\" value=\\\"\$Database\\\"><br/>
<br/><hr/><br/>
<table>
<tr><td>\$T_Prefixes : </td><td><input type=text name=\\\"cloneprefix\\\" value=\\\"clone1_ clone2_ clone3_\\\" $InputStyle required ></td></tr>
</table>
\$T_Warning : \$T_Lost_contents_clone.<br/>
</p>]]></zone_form>\"
	else
		FormTitle=\"\$T_Cloning failure \$Database \$T_on_service \$Service\"
		DATABASE_ON_ERROR \"\$T_No_archive \$Database \$T_on_service \$Service, \$T_save_first\"
	fi
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_copy)
	#TR T_Copying_database		Copying database : Copier la base de donnees
	#TR T_from_service		from service : depuis le service
	#TR T_to_another_service	to another service : vers un autre service
	#TR T_Copy_form			Form to copy database to another service : Formulaire pour copier la base de donnees vers un autre service
	#TR T_Target_service		Choose service to which database will be copied : Choisissez le service vers lequel la base de donnees sera copiee
	#TR T_Prefix_copy 		Set prefix added to copied database : Indiquez le prefixe ajoute au nom de la base de donnees copiee
	#TR T_Lost_content_copy		if copied database already exists, all current data will be lost definitively : le contenu actuel de la base de donnees copiee, si elle existe deja, sera definitivement perdu
	#TR T_Copying_failure 		Failure while copying database : Anomalie lors de la copie de la base de donnees
	#TR T_No_target_service 	No other service to copy the database can be copied : Pas d autre service vers lequel copier la base de donnees
	#TR T_Rights_failure		You are not allowed to copy database : Vous n'etes pas authorise a copier la base de donnees
	#TR T_User_rights		You must connect with administration rights to copy a database : Vous devez vous identifier avec des droits d administrateur pour copier la base
	#TR T_You_are 			You are : Vous etes
	echo "#! /bin/bash
$FormDbGenerics
$FormGetArchives
$FormGetServiceList
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_Copy
case \"\$Service0nBuzy\" in
Available)
	DATABASE_GET_ARCHIVES \"$XoeDir/xoe.services/\$Service/database/\$Database\"
	case \"\$LoginRole\" in
	admin*|Admin*)
		DATABASE_GET_SERVICE_LIST
		if [ ! -z \"\$optionarchive\" ] ; then
			if [ ! -z \"\$optionservice\" ] ; then
				FormTitle=\"\$T_Copying_database \$Database \$T_from_service \$Service \$T_to_another_service\"
				DATABASE_FORM_GENERICS \"\$FormTitle\"
				echo \"
	<zone_form><![CDATA[<p>\$T_Copy_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Database : \$Database<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database copyservice copyprefix\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"database\\\" value=\\\"\$Database\\\"><br/>
<br/><hr/><br/>
<table>
<tr><td>\$T_Target_service : </td><td><select name=\\\"copyservice\\\" $InputStyle >\$optionservice</select></td></tr>
<tr><td>\$T_Prefix_copy : </td><td><input type=text name=\\\"copyprefix\\\" value=\\\"copie_de_\\\" $InputStyle required ></td></tr>
</table>
\$T_Warning : \$T_Lost_content_copy.<br/>
</p>]]></zone_form>\"
			else
				FormTitle=\"T_Copying_failure \$Database \$T_from_service \$Service\"
				DATABASE_ON_ERROR \"\$T_No_target_service \$Database \$T_on_service \$Service\"
			fi
		else
			FormTitle=\"\$T_Copying_failure \$Database \$T_from_service \$Service\"
			DATABASE_ON_ERROR \"\$T_No_archive \$Database \$T_on_service \$Service, \$T_save_first\"
		fi
		;;
	*)
		FormTitle=\"\$T_Rights_failure \$Database \$T_from_service \$Service\"
		DATABASE_ON_ERROR \"\$T_User_rights \$Database \$T_from_service \$Service. \$T_You_are \$LoginRole\"
		;;
	esac
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_reference)
	#TR T_New_reference	Create a reference from the database : Creer une reference de la base de donnees
	#TR T_New_reference_failure	Failed to create a reference from the database : Echec de la creation d une reference de la base de donnees
	#TR T_New_reference_form	Form to create a reference from this database : Formulaire pour creer une reference de cette base de donnees
	#TR T_Lost_content_reference		Any previous reference of this database will be definitly lost : Toute reference precedente de la base de donnees sera definitivement supprimee
	echo "#! /bin/bash
$FormDbGenerics
$FormGetArchives
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_Reference
case \"\$Service0nBuzy\" in
Available)
	DATABASE_GET_ARCHIVES \"$XoeDir/xoe.services/\$Service/database/\$Database\"
	if [ ! -z \"\$optionarchive\" ] ; then
		FormTitle=\"\$T_New_reference \$Database \$T_on_service \$Service\"
		DATABASE_FORM_GENERICS \"\$FormTitle\"
		echo \"
	<zone_form><![CDATA[<p>\$T_New_reference_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Database : \$Database<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"database\\\" value=\\\"\$Database\\\">
<br/><hr/><br/>
\$T_Warning : \$T_Lost_content_reference.<br/>
</p>]]></zone_form>\"
	else
		FormTitle=\"\$T_New_reference_failure \$Database \$T_on_service \$Service\"
		DATABASE_ON_ERROR \"\$T_No_archive \$Database \$T_on_service \$Service, \$T_save_first\"
	fi
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_delete)
	#TR T_Delete_database	Remove database : Supprimer la base de donnees
	#TR T_Delete_form	Form to remove database : Formulaire pour supprimer la base de donnees
	#TR T_Lost_content_delete		All current data will be lost definitively : Le contenu actuel de la base de donnees supprimee sera definitivement perdu
	echo "#! /bin/bash
$FormDbGenerics
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_Delete
case \"\$Service0nBuzy\" in
Available)
	FormTitle=\"\$T_Delete_database \$Database \$T_on_service \$Service\"
	DATABASE_FORM_GENERICS \"\$FormTitle\"
	echo \"
	<zone_form><![CDATA[<p>\$T_Delete_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Database : \$Database<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"database\\\" value=\\\"\$Database\\\">
<br/><hr/><br/>
\$T_Warning : \$T_Lost_content_delete.<br/>
</p>]]></zone_form>\"
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_wipe_out)
	#TR T_Wipe_out_archives	Remove all archives of database : Effacer les sauvegardes de la base de donnees
	#TR T_Wipe_out_form	Form to remove all archives of database : Formulaire pour effacer les sauvegardes de la base de donnees
	#TR T_Lost_content_wipe_out		all archives of database will be lost definitively : toutes les archives des sauvegardes de la bases de donnees seront definitivement detruites
	echo "#! /bin/bash
$FormDbGenerics
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_Wipe_out
case \"\$Service0nBuzy\" in
Available)
	FormTitle=\"\$T_Wipe_out_archives \$Database du service \$Service\"
	DATABASE_FORM_GENERICS \"\$FormTitle\"
	echo \"
	<zone_form><![CDATA[<p>\$T_Wipe_out_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Database : \$Database<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"database\\\" value=\\\"\$Database\\\">
<br/><hr/><br/>
\$T_Warning : \$T_Lost_content_wipe_out.<br/>
</p>]]></zone_form>\"
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
button_dbupdate)
	#TR T_Db_update_form		Form to update this database : Formulaire pour mettre a jour cette base de donnees
	#TR T_Db_update			Automated version update of database : La montee automatique de version de la base de donnees
	#TR T_is_tryton_only		is only supported on tryton : n est supportee que par tryton

	#TR T_Db_update_failure		failure of automated version update of database : Echec de la montee automatique de version de la base de donnees
	#TR T_Lost_content_dbupdate	In case of failure, content of this database may need restoration : En cas d echec, le contenu de la base de donnees devra peut-etre etre restaure
	#TR T_No_db_update_archive	No valid archive for database : Pas de sauvegarde valide pour la base de donnees
	#TR T_db_update_save_first	first save database before update : vous devez sauvegarder la base de donnees avant mise a jour
	echo "#! /bin/bash
$FormDbGenerics
$FormGetErpName
$FormGetArchives
DATABASE_FORM_TOP_WINDOW
DATABASE_ON_BUZY \$T_DbUpdate
case \"\$Service0nBuzy\" in
Available)
	DATABASE_GET_ERP_NAME
	DATABASE_GET_ARCHIVES \"$XoeDir/xoe.services/\$Service/database/\$Database\"
	case \"\$erpname\" in
	tryton)
		if [ ! -z \"\$optionarchive\" ] ; then
			FormTitle=\"\$T_Db_update \$Database \$T_on_service \$Service\"
			DATABASE_FORM_GENERICS \"\$FormTitle\"
			echo \"
<zone_form><![CDATA[<p>\$T_Db_update_form<br/>
\$FormTitle<br/>
\$T_Service : \$Service<br/>
\$T_Database : \$Database<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"service database\\\">
<input type=\\\"hidden\\\" name=\\\"service\\\" value=\\\"\$Service\\\">
<input type=\\\"hidden\\\" name=\\\"database\\\" value=\\\"\$Database\\\">
<br/><hr/><br/>
\$T_Warning : \$T_Lost_content_dbupdate.<br/>
</p>]]></zone_form>\"
		else
			FormTitle=\"\$T_Cloning failure \$Database \$T_on_service \$Service\"
			DATABASE_ON_ERROR \"\$T_No_db_update_archive \$Database \$T_on_service \$Service, \$T_db_update_save_first\"
		fi
		;;
	*)
		FormTitle=\"\$T_Db_update_failure \$Database \$T_on_service \$Service\"
		DATABASE_ON_ERROR \"\$T_Db_update \$Database \$T_on_service \$Service \$T_is_tryton_only\"
		;;
	esac
	;;
esac
DATABASE_FORM_BOTTOM
" > $Templates.draft/$form_template
	;;
*)
	LOG_MESSAGE $LINENO -g TEMPLATE_BUTTON_FORM $* ERROR
	;;
esac
chmod 600 $Templates.draft/$form_template
}
#end 
#------------------------------------------------------------------------------
#last segment of --template command
	if [ -e "$Templates.draft" ] ; then rm -rf $Templates.draft ; fi
	mkdir $Templates.draft
	cp $Templates/templates.log $Templates.draft/templates.log
	chmod 750 $Templates.draft
	echo "Last templates on $Date" >> $Templates.draft/templates.log
	if [ -e "$Actions.draft" ] ; then rm -rf $Actions.draft ; fi
	mkdir $Actions.draft
	cp $Actions/actions.log $Actions.draft/actions.log
	chmod 750 $Actions.draft
	echo "Last actions on $Date" >> $Actions.draft/actions.log
	GET_DATA -page
	XoeDirConf=`cat $XoeDir/xoe.conf/xoe.services.conf | grep "^directory:server:"`

	ActionServiceList="button_editservicemenu button_renew button_start button_stop button_restart button_newcase button_company button_drop button_newmooc button_managemooc button_exam button_upload button_installarchive button_upgrade"
# button_downgrade"
	ButtonFormServiceList="button_editservicemenu button_newcase button_company button_drop button_newmooc button_managemooc button_exam button_upload button_installarchive button_upgrade"
#  button_downgrade"
	ButtonResultServiceList="$ActionServiceList"

	ActionDatabaseList="button_editdatabasemenu button_save button_snapshot button_restore button_clone button_copy button_reference button_delete button_wipe_out button_dbupdate"
	ButtonFormDatabaseList="button_editdatabasemenu button_restore button_clone button_copy button_reference button_delete button_wipe_out button_dbupdate"
	ButtonResultDatabaseList="$ActionDatabaseList"

	ActionList="$ActionServiceList $ActionDatabaseList"
	ButtonFormList="$ButtonFormServiceList $ButtonFormDatabaseList"
	ButtonResultList="$ButtonResultServiceList $ButtonResultDatabaseList"
	for action in $ActionList ; do
		TEMPLATE_ACTION $action
	done
	for template in $ButtonFormList ; do
		TEMPLATE_BUTTON_FORM $template ${template}_form.template
	done
	for template in $ButtonResultList ; do
		TEMPLATE_BUTTON_RESULT $template ${template}_result.template
	done
	chmod 750 $Templates.draft/*
	$Sudo chown -R $XoeAuthorizedUser:$HttpUser $Templates.draft
	chmod 750 $Actions.draft/*
	$Sudo chown -R $XoeAuthorizedUser:$HttpUser $Actions.draft
	CHECK_BUZY $LINENO set
	mv $Templates $Templates.removed
	mv $Templates.draft $Templates
	mv $Actions $Actions.removed
	mv $Actions.draft $Actions
	CHECK_BUZY $LINENO release
	LOG_MESSAGE $LINENO -g --template buttons templates and actions have been updated
	rm -rf $Templates.removed
	rm -rf $Actions.removed
	;;
--draw*)
	#TR T_Page_top	Main menu : Menu principal
	#TR T_Page_back	Back to dashboard : Retour au tableau de bord

	PageTop="<![CDATA[<a href=\"$SiteUrl\"><img src=\"images/top.png\" alt=\"$T_Page_top\" title=\"$T_Page_top\" /></a>]]>"
	PageBack1="<![CDATA[<hr/><a href=\"$SiteUrl\"><img src=\"images/back.png\" alt=\"$T_Page_back\" title=\"$T_Page_back\" /></a>]]>"
	PageBack2="<![CDATA[<a href=\"$SiteUrl\"><img src=\"images/back.png\" alt=\"$T_Page_back\" title=\"$T_Page_back\" /></a><hr/>]]>"
#------------------------------------------------------------------------------
FILL_DATABASE_MENU ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g FILL_DATABASE_MENU $*
button_name="$1"
case "$button_name" in
header)
	DatabaseMenuContent="
<zone name=\"zone.$Service.$Database.detail\">
	<zone_title><![CDATA[<title>$T_Detailled_database $Database $T_on_service $Service</title>]]></zone_title>
	<zone_type>database_detail</zone_type>
<zone name=\"zone.$Service.$Database.buttons\">
	<zone_position>zbuttons</zone_position>"
	;;
editdatabasemenu)
		DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_editdatabasemenu\">
	<zone_on_click>--page zone.$Service.$Database.button_editdatabasemenu $Service.$Database.button_editdatabasemenu_form.template</zone_on_click>
	<zone_doc_over>$ButtonEditDatabaseMenuDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonEditDatabaseMenuStatus</zone_status>
	<zone_label>$T_EditDatabaseMenu</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_editdatabasemenu\" --> </zone>"
	;;
save)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_save\">
	<zone_on_click>--on_click zone.$Service.$Database.button_save $Service.$Database.button_save_result.template $Service.$Database.button_save.template $Service $Database</zone_on_click>
	<zone_doc_over> $ButtonSaveDoc </zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonSaveStatus</zone_status>
	<zone_label>$T_Save</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_save\" --> </zone>"
	;;
snapshot)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_snapshot\">
	<zone_on_click>--on_click zone.$Service.$Database.button_snapshot $Service.$Database.button_snapshot_result.template $Service.$Database.button_snapshot.template $Service $Database</zone_on_click>
	<zone_doc_over> $ButtonSnapshotDoc </zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonSnapshotStatus</zone_status>
	<zone_label>$T_Snapshot</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_snapshot\" --> </zone>"
	;;
restore)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_restore\">
	<zone_on_click>--page zone.$Service.$Database.button_restore $Service.$Database.button_restore_form.template</zone_on_click>
	<zone_doc_over> $ButtonRestoreDoc </zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonRestoreStatus</zone_status>
	<zone_label>$T_Restore...</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_restore\" --> </zone>"
	;;
clone)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_clone\">
	<zone_on_click>--page zone.$Service.$Database.button_clone $Service.$Database.button_clone_form.template</zone_on_click>
	<zone_doc_over>$ButtonCloneDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonCloneStatus</zone_status>
	<zone_label>$T_Clone... </zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_clone\" --> </zone>"
	;;
copy)
#	case "$LoginRole" in
#	admin*|Admin*)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_copy\">
	<zone_on_click>--page zone.$Service.$Database.button_copy $Service.$Database.button_copy_form.template</zone_on_click>
	<zone_doc_over>$ButtonCopyDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonCopyStatus</zone_status>
	<zone_label>$T_Copy...</zone_label> -->
<!-- end \"zone.$Service.$CommentDatabase.button_copy\" --> </zone>"
#		;;
#	esac
	;;
reference)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_reference\">
	<zone_on_click>--page zone.$Service.$Database.button_reference $Service.$Database.button_reference_form.template</zone_on_click>
	<zone_doc_over>$ButtonReferenceDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonReferenceStatus</zone_status>
	<zone_label>$T_Reference...</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_reference\" --> </zone>"
	;;
delete)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_delete\">
	<zone_on_click>--page zone.$Service.$Database.button_delete $Service.$Database.button_delete_form.template</zone_on_click>
	<zone_doc_over>$ButtonDeleteDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonDeleteStatus</zone_status>
	<zone_label>$T_Delete...</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_delete\" --> </zone>"
	;;
wipe_out)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_wipe_out\">
	<zone_on_click>--page zone.$Service.$Database.button_wipe_out $Service.$Database.button_wipe_out_form.template</zone_on_click>
	<zone_doc_over>$ButtonWipeOutDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonWipeOutStatus</zone_status>
	<zone_label>$T_Wipe_out...</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_wipe_out\" --> </zone>"
	;;
dbupdate)
	DatabaseMenuContent="$DatabaseMenuContent
<zone name=\"zone.$Service.$Database.button_dbupdate\">
	<zone_on_click>--page zone.$Service.$Database.button_dbupdate $Service.$Database.button_dbupdate_form.template</zone_on_click>
	<zone_doc_over>$ButtonDbUpdateDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonDbUpdateStatus</zone_status>
	<zone_label>$T_DbUpdate...</zone_label>
<!-- end \"zone.$Service.$CommentDatabase.button_dbupdate\" --> </zone>"
	;;
end)
	DatabaseMenuContent="$DatabaseMenuContent
<!-- end \"zone.$Service.$CommentDatabase.buttons\" --> </zone>"
	;;
esac
}
#end 
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
FILL_SERVICE_MENU ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g FILL_SERVICE_MENU $*
button_name="$1"
case "$button_name" in
header)
	ServiceMenuContent="
<zone name=\"zone.$Service.detail\">
	<zone_title><![CDATA[<title>$T_Detailled_service $Service</title>]]></zone_title>
	<zone_type>service_detail</zone_type>
<zone name=\"zone.$Service.buttons\">
	<zone_position>zbuttons</zone_position>"
	;;
editservicemenu)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_editservicemenu\">
	<zone_on_click>--page zone.$Service.button_editservicemenu $Service.button_editservicemenu_form.template</zone_on_click>
	<zone_doc_over>$ButtonEditServiceMenuDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonEditServiceMenuStatus</zone_status>
	<zone_label>$T_EditServiceMenu</zone_label>
<!-- end \"zone.$Service.button_editservicemenu\" --> </zone>"
	;;
renew)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_renew\">
	<zone_on_click>--on_click zone.$Service.button_renew $Service.button_renew_result.template $Service.button_renew.template $Service</zone_on_click>
	<zone_doc_over>$ButtonRenewDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonRenewStatus</zone_status>
	<zone_label>$T_Renew</zone_label>
<!-- end \"zone.$Service.button_renew\" --> </zone>"

	;;
start)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_start\">
	<zone_on_click>--on_click zone.$Service.button_start $Service.button_start_result.template $Service.button_start.template $Service</zone_on_click>
	<zone_doc_over>$ButtonStartDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonStartStatus</zone_status>
	<zone_label>$T_Start</zone_label>
<!-- end \"zone.$Service.button_start\" --> </zone>"
	;;
stop)
		ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_stop\">
	<zone_on_click>--on_click zone.$Service.button_stop $Service.button_stop_result.template $Service.button_stop.template $Service</zone_on_click>
	<zone_doc_over>$ButtonStopDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonStopStatus</zone_status>
	<zone_label>$T_Stop</zone_label>
<!-- end \"zone.$Service.button_stop\" --> </zone>"
	;;
restart)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_restart\">
	<zone_on_click>--on_click zone.$Service.button_restart $Service.button_restart_result.template $Service.button_restart.template $Service</zone_on_click>
	<zone_doc_over>$ButtonRestartDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonRestartStatus</zone_status>
	<zone_label>$T_Restart</zone_label>
<!-- end \"zone.$Service.button_restart\" --> </zone>"
	;;
newcase)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_newcase\">
	<zone_on_click>--page zone.$Service.button_newcase $Service.button_newcase_form.template</zone_on_click>
	<zone_doc_over>$ButtonNewCaseDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonNewCaseStatus</zone_status>
	<zone_label>$T_New_case...</zone_label>
<!-- end \"zone.$Service.button_newcase\" --> </zone>"
	;;
company)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_company\">
	<zone_on_click>--page zone.$Service.button_company $Service.button_company_form.template</zone_on_click>
	<zone_doc_over>$ButtonCompanyDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonCompanyStatus</zone_status>
	<zone_label>$T_Company...</zone_label>
<!-- end \"zone.$Service.button_company\" --> </zone>"
	;;
drop)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_drop\">
	<zone_on_click>--page zone.$Service.button_drop $Service.button_drop_form.template</zone_on_click>
	<zone_doc_over>$ButtonDropDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonDropStatus</zone_status>
	<zone_label>$T_Drop...</zone_label>
<!-- end \"zone.$Service.button_drop\" --> </zone>"
	;;
newmooc)
	# *education|*)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_newmooc\">
	<zone_on_click>--page zone.$Service.button_newmooc $Service.button_newmooc_form.template</zone_on_click>
	<zone_doc_over>$ButtonNewMoocDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonNewMoocStatus</zone_status>
	<zone_label>$T_Mooc...</zone_label>
<!-- end \"zone.$Service.button_newmooc\" --> </zone>"
	;;
managemooc)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_managemooc\">
	<zone_on_click>--page zone.$Service.button_managemooc $Service.button_managemooc_form.template</zone_on_click>
	<zone_doc_over>$ButtonManageMoocDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonManageMoocStatus</zone_status>
	<zone_label>$T_Managemooc...</zone_label>
<!-- end \"zone.$Service.button_managemooc\" --> </zone>"
	;;
exam)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_exam\">
	<zone_on_click>--page zone.$Service.button_exam $Service.button_exam_form.template</zone_on_click>
	<zone_doc_over>$ButtonExamDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonExamStatus</zone_status>
	<zone_label>$T_Exam...</zone_label>
<!-- end \"zone.$Service.button_exam\" --> </zone>"
	;;
upload)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_upload\">
	<zone_on_click>--page zone.$Service.button_upload $Service.button_upload_form.template</zone_on_click>
	<zone_doc_over>$ButtonUploadDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonUploadStatus</zone_status>
	<zone_label>$T_Upload...</zone_label>
<!-- end \"zone.$Service.button_upload\" --> </zone>"
	;;
installarchive)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_installarchive\">
	<zone_on_click>--page zone.$Service.button_installarchive $Service.button_installarchive_form.template</zone_on_click>
	<zone_doc_over>$ButtonInstallarchiveDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonInstallarchiveStatus</zone_status>
	<zone_label>$T_installarchive...</zone_label>
<!-- end \"zone.$Service.button_installarchive\" --> </zone>"
	;;
upgrade)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_upgrade\">
	<zone_on_click>--page zone.$Service.button_upgrade $Service.button_upgrade_form.template</zone_on_click>
	<zone_doc_over>$ButtonUpgradeDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonUpgradeStatus</zone_status>
	<zone_label>$T_Upgrade...</zone_label>
<!-- end \"zone.$Service.button_upgrade\" --> </zone>"
	;;
downgrade)
	ServiceMenuContent="$ServiceMenuContent
<zone name=\"zone.$Service.button_downgrade\">
	<zone_on_click>--page zone.$Service.button_downgrade $Service.button_downgrade_form.template</zone_on_click>
	<zone_doc_over>$ButtonDowngradeDoc</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>$ButtonDowngradeStatus</zone_status>
	<zone_label>$T_Downgrade...</zone_label>
<!-- end \"zone.$Service.button_downgrade\" --> </zone>"
	;;
end)
		ServiceMenuContent="$ServiceMenuContent
<!-- end \"zone.$Service.buttons\" --> </zone>"
	;;
esac
}
#end 
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
DRAW_DETAIL ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g DRAW_DETAIL $*
#DRAW_DETAIL comment -init|-new_page dd_detail_type comment file_to_create
dd_call="$1-DRAW_DETAIL"
shift
#$1 is -init or -new_page
dd_init_or_newpage="$1"
shift
dd_detail_type="$1"
shift
dd_file_to_create="$*"
SHAPE_XML_FILE $dd_call-$LINENO $dd_init_or_newpage $dd_file_to_create

case "$dd_detail_type" in
-database_menu)

	#TR T_Detailled_database	Detailled information about database : Information detaillee sur la base de donnees
	#TR T_Save	Save : Sauvegarder
	#TR T_Snapshot	Save periodically ; Sauvegarder periodiquement
	#TR T_Restore	Restore : Restaurer
	#TR T_Clone	Clone : Cloner
	#TR T_Copy	Copy : Copier
	#TR T_Reference	Reference : Reference
	#TR T_Delete	Delete : Supprimer
	#TR T_Wipe_out	Wipe out : Effacer
	#TR T_DbUpdate	Update : Mise a jour
	#TR T_EditDatabaseMenu +/- : +/-
	#LOG_MESSAGE $LINENO -g DRAW_DETAIL $* DatabaseButtonsFullList $DatabaseButtonsFullList ServiceButtons $ServiceButtons
	FILL_DATABASE_MENU header
	for button in $DatabaseButtonsFullList ; do
		case "$DatabaseButtons" in
		*$button*)
			FILL_DATABASE_MENU $button
			;;
		esac
	done
	FILL_DATABASE_MENU end
	if [ ! -z $XmlFile ] ; then
		echo "$DatabaseMenuContent" >> $XmlFile
	else
		echo "$DatabaseMenuContent"
	fi
	;;
-database)
	#TR T_Database_Info	Information about database : Information sur la base de donnees
	DatabaseDetailContent="
<zone name=\"zone.pageback1.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$PageBack1</zone_html>
<!-- end \"zone.pageback1.zone\" --> </zone>
<zone name=\"zone.$Service.$Database.map\">
	<zone_position>zwide</zone_position>
<zone name=\"zone.$Service.name\">
	<zone_on_click>--page zone.$Service.map $Service.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_position>zleft</zone_position>
	<zone_type>service_name</zone_type>
	<zone_status>$ServiceStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$ServiceImage\" alt=\"S \" /> $Service]]></zone_label>
<!-- end \"zone.$Service.name\" --> </zone>
<zone name=\"zone.$Service.$Database.name\">
	<zone_position>zcenter</zone_position>
	<zone_type>database</zone_type>
	<zone_status>$DbStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$DiskImage\" alt=\"D \"/> $Database]]></zone_label>
<!-- end \"zone.$Service.$Database.name\" --> </zone>
<zone name=\"zone.$Service.$Database.archive\">
	<zone_position>zright</zone_position>
	<zone_type>archive</zone_type>
	<zone_status>$ArchiveStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$TapeImage\" alt=\"A \"/> $ArchiveDate]]></zone_label>
<!-- end \"zone.$Service.$Database.archive\" --> </zone>
<!-- end \"zone.$Service.$Database.map\" --> </zone>
<zone name=\"zone.$Service.$Database.info\">
	<zone_position>zwide</zone_position>
	<zone_type>database_information</zone_type>
	<zone_html><![CDATA[<p>$T_Database_Info $Database $T_on_service $Service<br/>$DbInformation</p>]]></zone_html>
<!-- end \"zone.$Service.$Database.info\" --> </zone>



<zone name=\"zone.$Service.$Database.lastactions_detail\">
	<zone_position>zlastactions</zone_position>
	<zone_type>database_lastactions</zone_type>
	<zone_html><![CDATA[<p>$DatabaseLastActions</p>]]></zone_html>
<!-- end \"zone.$Service.$Database.lastactions_detail\" --> </zone>



<zone name=\"zone.$Service.$Database.log_tail\">
	<zone_position>zlogtail</zone_position>
	<zone_type>service_log</zone_type>
	<zone_window>zone-$Service.$Database.log_tail</zone_window>
	<zone_on_click>--page zone.$Service.$Database.log_tail $Service.log_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_status>$ServiceLogTailStatus</zone_status>
	<zone_html>$ServiceLogTail</zone_html>
<!-- end \"zone.$Service.log_tail_map\" --> </zone>
<zone name=\"zone.pageback2.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$PageBack2</zone_html>
<!-- end \"zone.pageback2.zone\" --> </zone>
<!-- end \"zone.$Service.$Database.detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$DatabaseDetailContent" >> $XmlFile
	else
		echo "$DatabaseDetailContent"
	fi
	;;
-database_lastactions)
	DatabaseLastActionsDetailContent="
<zone name=\"zone.$Service.$Database.lastactions_detail\">
	<zone_type>database_lastactions</zone_type>
	<zone_html><![CDATA[<hr/><p>$DatabaseLastActions</p><hr/>]]></zone_html>
<!-- end \"zone.$Service.$Database.lastactions_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$DatabaseLastActionsDetailContent" >> $XmlFile
	else
		echo "$DatabaseLastActionsDetailContent"
	fi
	echo "DRAW_DETAIL $XmlFile on $Date mode $ServerMode $LINENO" >> $DrawingsLog
	;;
-service_menu)
	#TR T_Detailled_service	Detailled information about service : Information detaillee sur le service
	#TR T_Renew Renew : Prolonger
	#TR T_Start Start : Demarrer
	#TR T_Stop Stop : Arreter
	#TR T_Restart Restart : Redemarrer
	#TR T_New_case New case : Cas
	#TR T_Company Company : Societe
	#TR T_Drop Drop : Supprimer
	#TR T_Mooc New course : Cours
	#TR T_Managemooc Manage courses : Gerer les cours
	#TR T_Exam Exam sessions : Examens
	#TR T_Upload	Upload : Telecharger
	#TR T_installarchive	Archives : Archives
	#TR T_Downgrade Downgrade : Retablir
	#TR T_Upgrade	Reinstall : Reinstaller
	#TR T_EditServiceMenu +/- : +/-
#ActionList="button_editservicemenu button_renew button_start button_stop button_restart button_newcase button_company button_drop button_newmooc button_managemooc button_exam button_upload button_installarchive button_upgrade button_editdatabasemenu button_save button_snapshot button_restore button_clone button_copy button_reference button_delete button_wipe_out button_dbupdate"
# button_downgrade
	#LOG_MESSAGE $LINENO -g DRAW_DETAIL $* ServiceButtonsFullList $ServiceButtonsFullList ServiceButtons $ServiceButtons
	FILL_SERVICE_MENU header
	for button in $ServiceButtonsFullList ; do
		case "$ServiceButtons" in
		*$button*)
			FILL_SERVICE_MENU $button
			;;
		esac
	done
	FILL_SERVICE_MENU end
	if [ ! -z $XmlFile ] ; then
		echo "$ServiceMenuContent" >> $XmlFile
	else
		echo "$ServiceMenuContent"
	fi
	;;
-service)
	ServiceDetailContent="
<zone name=\"zone.pageback1.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$PageBack1</zone_html>
<!-- end \"zone.pageback1.zone\" --> </zone>
<zone name=\"zone.$Service.map\">
	<zone_position>zwide</zone_position>
<zone name=\"zone.$Service.name\">
	<zone_on_click>--page zone.$Service.map $Service.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_type>service_name</zone_type>
	<zone_status>$ServiceStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$ServiceImage\" alt=\"S \"/> $Service]]></zone_label>
<!-- end \"zone.$Service.name\" --> </zone>
<zone name=\"zone.$Service.running\">
	<zone_type>service_running</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_label>$ServiceRunning - role $ServiceRole</zone_label>
<!-- end \"zone.$Service.running\" --> </zone>
<zone name=\"zone.$Service.version\">
	<zone_type>service_version</zone_type>
	<zone_status>$ServiceStatus</zone_status>
	<zone_label>$ServiceErpName - $ServiceVersion</zone_label>
<!-- end \"zone.$Service.version\" --> </zone>
<zone name=\"zone.$Service.url\">
	<zone_type>service_information</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_html>$ServiceLoginUrl</zone_html>
<!-- end \"zone.$Service.url\" --> </zone>
<zone name=\"zone.$Service.last_login\">
	<zone_type>service_last_login</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_html>$ServiceLastLogin</zone_html>
<!-- end \"zone.$Service.last_login\" --> </zone>
<zone name=\"zone.$Service.documentation\">
	<zone_type>service_information</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_html>$ServiceSummary</zone_html>
<!-- end \"zone.$Service.documentation\" --> </zone>
<!-- end \"zone.$Service.map\" --> </zone>
<zone name=\"zone.$Service.configuration\">
	<zone_position>zinfo</zone_position>
	<zone_type>service_configuration</zone_type>
	<zone_window>zone-$Service.configuration.map</zone_window>
	<zone_on_click>--page zone.$Service.configuration $Service.configuration_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_html><![CDATA[<p>$ServiceInformation</p>]]></zone_html>
<!-- end \"zone.$Service.configuration\" --> </zone>
<zone name=\"zone.$Service.log_tail_map\">
	<zone_position>zlogtail</zone_position>
	<zone_type>service_log</zone_type>
	<zone_window>zone-$Service.log_tail.map</zone_window>
	<zone_on_click>--page zone.$Service.log_tail_map $Service.log_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_status>$ServiceLogTailStatus</zone_status>
	<zone_html>$ServiceLogTail</zone_html>
<!-- end \"zone.$Service.log_tail_map\" --> </zone>
<zone name=\"zone.pageback2.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$PageBack2</zone_html>
<!-- end \"zone.pageback2.zone\" --> </zone>
<!-- end \"zone.$Service.detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$ServiceDetailContent" >> $XmlFile
	else
		echo "$ServiceDetailContent"
	fi
	;;
-configuration)
	ConfigurationDetailContent="
<zone name=\"zone.$Service.configuration_detail\">
	<zone_type>service_configuration</zone_type>
	<zone_html><![CDATA[<hr/><p>$ServiceInformation</p><hr/>]]></zone_html>
<!-- end \"zone.$Service.configuration_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$ConfigurationDetailContent" >> $XmlFile
	else
		echo "$ConfigurationDetailContent"
	fi
	echo "DRAW_DETAIL $XmlFile on $Date mode $ServerMode $LINENO" >> $DrawingsLog
	;;
-instructions)
	InstructionsDetailContent="
<zone name=\"zone.$Service.instructions_detail\">
	<zone_type>service_instructions</zone_type>
	<zone_html><![CDATA[<hr/><p>$ServiceInstructions</p><hr/>]]></zone_html>
<!-- end \"zone.$Service.instructions_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$InstructionsDetailContent" >> $XmlFile
	else
		echo "$InstructionsDetailContent"
	fi
	echo "DRAW_DETAIL $XmlFile on $Date mode $ServerMode $LINENO" >> $DrawingsLog
	;;
-lastactions)
	LastActionsDetailContent="
<zone name=\"zone.$Service.lastactions_detail\">
	<zone_type>service_lastactions</zone_type>
	<zone_html><![CDATA[<hr/><p>$ServiceLastActions</p><hr/>]]></zone_html>
<!-- end \"zone.$Service.lastactions_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$LastActionsDetailContent" >> $XmlFile
	else
		echo "$LastActionsDetailContent"
	fi
	echo "DRAW_DETAIL $XmlFile on $Date mode $ServerMode $LINENO" >> $DrawingsLog
	;;
-anomalies)
	AnomaliesDetailContent="
<zone name=\"zone.$Service.anomalies_detail\">
	<zone_type>service_anomalies</zone_type>
	<zone_html><![CDATA[<hr/><p>$ServiceLogErrors</p><hr/>]]></zone_html>
<!-- end \"zone.$Service.anomalies_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$AnomaliesDetailContent" >> $XmlFile
	else
		echo "$LastActionsDetailContent"
	fi
	echo "DRAW_DETAIL $XmlFile on $Date mode $ServerMode $LINENO" >> $DrawingsLog
	;;
-log)
	#disabled in service collected data
	LogDetailContent="
<zone name=\"zone.$Service.log_detail\">
	<zone_type>service_log</zone_type>
	<zone_html>$ServiceLogDetail</zone_html>
<!-- end \"zone.$Service.log_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$LogDetailContent" >> $XmlFile
	else
		echo "$LogDetailContent"
	fi
	echo "DRAW_DETAIL $XmlFile on $Date mode $ServerMode $LINENO" >> $DrawingsLog
	;;
-contract)	
	ContractDetailContent="
<zone name=\"zone.contract_detail\">
	<zone_type>contract</zone_type>
	<zone_html><![CDATA[<hr/><p>$ContractZoneContent</p><hr/>]]></zone_html>
<!-- end \"zone.contract_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$ContractDetailContent" >> $XmlFile
	else
		echo "$ContractDetailContent"
	fi
	;;
-admin_guide)	
	Admin_guideDetailContent="
<zone name=\"zone.admin_guide_detail\">
	<zone_type>admin_guide</zone_type>
	<zone_html><![CDATA[<hr/><p>$AdminGuideZoneContent</p><hr/>]]></zone_html>
<!-- end \"zone.admin_guide_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$Admin_guideDetailContent" >> $XmlFile
	else
		echo "$Admin_guideDetailContent"
	fi
	;;
-open_service)	
	Open_serviceDetailContent="
<zone name=\"zone.open_service_detail\">
        <zone_refresh><![CDATA[<meta http-equiv=\"Refresh\" content=\"600\" />]]></zone_refresh>
	<zone_type>manage_service</zone_type>
	<zone_html><![CDATA[<hr/>$OpenServiceZoneContent<hr/>]]></zone_html>
<!-- end \"zone.open_service_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$Open_serviceDetailContent" >> $XmlFile
	else
		echo "$Open_serviceDetailContent"
	fi
	;;
-close_service)	
	Close_serviceDetailContent="
<zone name=\"zone.close_service_detail\">
	<zone_type>manage_service</zone_type>
	<zone_html><![CDATA[<hr/><p>$CloseServiceZoneContent</p><hr/>]]></zone_html>
<!-- end \"zone.close_service_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$Close_serviceDetailContent" >> $XmlFile
	else
		echo "$Close_serviceDetailContent"
	fi
	;;
-general_log)	
	GeneralLogDetailContent="
<zone name=\"zone.log_detail\">
	<zone_type>general_log</zone_type>
	<zone_html>$LogDetail</zone_html>
<!-- end \"zone.log_detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$GeneralLogDetailContent" >> $XmlFile
	else
		echo "$GeneralLogDetailContent"
	fi
	;;
-default)
	#TR T_data_collect Collecting detailled information on the server : Collecte des informations detaillees sur le serveur
	#TR T_Search Searching : Recherche
	#TR T_available available : des actions
	#TR T_actions actions : disponibles
	#TR T_Analysing Analysing server status : Analyse en cours du serveur
	#TR T_Wait Please wait a little more : Merci d'attendre encore quelques secondes


	DefaultDetailContent="<zone name=\"zone.no_service.detail\">
	<zone_title><![CDATA[<title>$T_data_collect</title>]]></zone_title>
	<zone_type>service_detail</zone_type>
<zone name=\"zone.no_service.buttons\">
	<zone_position>zbuttons</zone_position>
<zone name=\"zone.no_service.button\">
	<zone_doc_over>Action</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>unknown</zone_status>
	<zone_label>$T_Search</zone_label>
<!-- end \"zone.no_service.button\" --> </zone>
<zone name=\"zone.no_service.button\">
	<zone_doc_over>Action</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>unknown</zone_status>
	<zone_label>$T_available</zone_label>
<!-- end \"zone.no_service.button\" --> </zone>
<zone name=\"zone.no_service.button\">
	<zone_doc_over>Action</zone_doc_over>
	<zone_position>zbutton</zone_position>
	<zone_type>button</zone_type>
	<zone_status>unknown</zone_status>
	<zone_label>$T_actions...</zone_label>
<!-- end \"zone.no_service.button\" --> </zone>
<!-- end \"zone.no_service.buttons\" --> </zone>
<zone name=\"zone.pageback1.zone\">
	<zone_position>zwide</zone_position>
	<zone_html><![CDATA[<hr/><a href=\".\"><img src=\"images/back.png\" alt=\"$T_Page_back\" title=\"$T_Page_back\" /></a>]]></zone_html>
<!-- end \"zone.pageback1.zone\" --> </zone>
<zone name=\"zone.no_service.map\">
	<zone_position>zwide</zone_position>
<zone name=\"zone.no_service.name\">
	<zone_type>service_name</zone_type>
	<zone_status>unknown</zone_status>
	<zone_label><![CDATA[<img src=\"images/disk.png\" alt=\"S \"/> $T_Analysing ...]]></zone_label>
<!-- end \"zone.no_service.name\" --> </zone>
<zone name=\"zone.no_service.running\">
	<zone_type>service_running</zone_type>
	<zone_status>unknown</zone_status>
	<zone_label></zone_label>
<!-- end \"zone.no_service.running\" --> </zone>
<zone name=\"zone.no_service.version\">
	<zone_type>service_version</zone_type>
	<zone_status>unknown</zone_status>
	<zone_label>$T_data_collect. $T_Wait....</zone_label>
<!-- end \"zone.log.zone\" --> </zone>
<!-- end \"zone.no_service.map\" --> </zone>
<zone name=\"zone.pageback2.zone\">
	<zone_position>zwide</zone_position>
	<zone_html><![CDATA[<a href=\".\"><img src=\"images/back.png\" alt=\"$T_Page_back\" title=\"$T_Page_back\" /></a><hr/>]]></zone_html>
<!-- end \"zone.pageback2.zone\" --> </zone>
<!-- end \"zone.no_service.detail\" --> </zone>"
	if [ ! -z $XmlFile ] ; then
		echo "$DefaultDetailContent" >> $XmlFile
	else
		echo "$DefaultDetailContent"
	fi
	;;
esac
case "$1" in
-new_page)
	SHAPE_XML_FILE $dd_call-$LINENO -end_page $dd_file_to_create
	;;
esac
}
# end DRAW_DETAIL
#------------------------------------------------------------------------------
DRAW_MAP ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g DRAW_MAP $*
SHAPE_XML_FILE DRAW_MAP-$LINENO $1 $4 $3
map_type="$2"
map_file="$3"
case "$map_type" in
-admin_guide)
	Admin_guideMapContent="
<zone name=\"zone.admin_guide_map\">
	<zone_window>zone-admin_guide_detail</zone_window>
	<zone_on_click>--page zone.admin_guide_detail admin_guide_detail.draw</zone_on_click>
	<zone_doc_over>$T_Server_log TODO</zone_doc_over>
	<zone_position>zadmin_guide</zone_position>
	<zone_type>admin_guide</zone_type>
	<zone_html><![CDATA[<p>$AdminGuideZoneContent</p>]]></zone_html>
<!-- end \"zone.admin_guide_map\" --> </zone>"
	echo "$Admin_guideMapContent" >> $map_file
	;;
-anomalies)
	AnomaliesMapContent="
<zone name=\"zone.$Service.anomalies_map\">
	<zone_window>zone-$Service-anomalies_detail</zone_window>
	<zone_on_click>--page zone.$Service.anomalies_detail $Service.anomalies_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_position>zanomalies</zone_position>
	<zone_type>service_anomalies</zone_type>
	<zone_html><![CDATA[<p>$ServiceLogErrors</p>]]></zone_html>
<!-- end \"zone.$Service.anomalies_map\" --> </zone>"
	echo "$AnomaliesMapContent" >> $map_file
	;;
-close_service)
	CloseServiceMapContent="
<zone name=\"zone.close_service.map\">
	<zone_window>zone-close_service_detail</zone_window>
	<zone_on_click>--page zone.close_service_detail close_service_detail.draw</zone_on_click>
	<zone_doc_over>close_service to be documented</zone_doc_over>
	<zone_position>zclose_service</zone_position>
	<zone_type>manage_service</zone_type>
	<zone_html><![CDATA[<p>Close service form<br/>$CloseServiceZoneContent</p>]]></zone_html>
<!-- end \"zone.closeservice.zone\" --> </zone>"
	echo "$CloseServiceMapContent" >> $map_file
	;;
-contract)
	ContractMapContent="
<zone name=\"zone.contract_map\">
	<zone_window>zone-contract_detail</zone_window>
	<zone_on_click>--page zone.contract_detail contract_detail.draw</zone_on_click>
	<zone_doc_over>$T_Server_log TODO</zone_doc_over>
	<zone_position>zcontract</zone_position>
	<zone_type>contract</zone_type>
	<zone_html><![CDATA[<p>$ContractZoneContent</p>]]></zone_html>
<!-- end \"zone.contract_map\" --> </zone>"
	echo "$ContractMapContent" >> $map_file
	;;
-database)
	DatabaseMapContent="
<zone name=\"zone.$Service.$Database.map\">
	<zone_on_click>--page zone.$Service.$Database.map $Service.$Database.detail.draw</zone_on_click>
	<zone_doc_over>$DbDoc. $ArchiveDoc</zone_doc_over>
	<zone_position>zdatabase</zone_position>
<zone name=\"zone.$Service.$Database.name\">
	<zone_position>zcenter</zone_position>
	<zone_type>database</zone_type>
	<zone_status>$DbStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$DiskImage\" alt=\"D \"/> $Database]]></zone_label>
<!-- end \"zone.$Service.$CommentDatabase.name\" --> </zone>
<zone name=\"zone.$Service.$Database.archive\">
	<zone_position>zright</zone_position>
	<zone_type>archive</zone_type>
	<zone_status>$ArchiveStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$TapeImage\" alt=\"A \"/> $ArchiveDate]]></zone_label>
<!-- end \"zone.$Service.$CommentDatabase.archive\" --> </zone>
<!-- end \"zone.$Service.$CommentDatabase.map\" --> </zone>"
	echo "$DatabaseMapContent" >> $map_file
	;;
-database_lastactions)
	DatabaseLastActionsMapContent="
<zone name=\"zone.$Service.$Database.lastactions_map\">
	<zone_window>zone-$Service-$Database-lastactions_detail</zone_window>
	<zone_on_click>--page zone.$Service.$Database.lastactions_detail $Service.$Database.lastactions_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_position>zlastactions</zone_position>
	<zone_type>database_lastactions</zone_type>
	<zone_html><![CDATA[<p>$DatabaseLastActions</p>]]></zone_html>
<!-- end \"zone.$Service.$Database.lastactions_map\" --> </zone>"
	echo "$DatabaseLastActionsMapContent" >> $map_file
	;;
-general_log)
	#TR T_Server_log Server Log : Log general du serveur
	GeneralLogMapContent="
<zone name=\"zone.generallog.zone\">
	<zone_menu><![CDATA[<a href=\"index.php#zone.log_tail_map\"><div class=\"menu_element\"><div class=\"$LogTailStatus\">Log</div></div></a>]]></zone_menu>
	<zone_position>zlog</zone_position>
<zone name=\"zone.log_tail_map\">
	<zone_window>zone-general-log_detail</zone_window>
	<zone_on_click>--page zone.log_tail_map log_detail.draw</zone_on_click>
	<zone_doc_over>$T_Server_log</zone_doc_over>
	<zone_type>general_log</zone_type>
	<zone_status>$LogTailStatus</zone_status>
	<zone_html>$LogTail</zone_html>
<!-- end \"zone.log_tail_map\" --> </zone>
<!-- end \"zone.log.zone\" --> </zone>"
	echo "$GeneralLogMapContent" >> $map_file
	;;
-instructions)
	InstructionsMapContent="
<zone name=\"zone.$Service.instructions_map\">
	<zone_window>zone-$Service-instructions_detail</zone_window>
	<zone_on_click>--page zone.$Service.instructions_detail $Service.instructions_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_position>zinstructions</zone_position>
	<zone_type>service_instructions</zone_type>
	<zone_html><![CDATA[<p>$ServiceInstructions</p>]]></zone_html>
<!-- end \"zone.$Service.instructions_map\" --> </zone>"
	echo "$InstructionsMapContent" >> $map_file
	;;
-lastactions)
	LastActionsMapContent="
<zone name=\"zone.$Service.lastactions_map\">
	<zone_window>zone-$Service-lastactions_detail</zone_window>
	<zone_on_click>--page zone.$Service.lastactions_detail $Service.lastactions_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_position>zlastactions</zone_position>
	<zone_type>service_lastactions</zone_type>
	<zone_html><![CDATA[<p>$ServiceLastActions</p>]]></zone_html>
<!-- end \"zone.$Service.lastactions_map\" --> </zone>"
	echo "$LastActionsMapContent" >> $map_file
	;;
-log)
	LogMapContent="
<zone name=\"zone.$Service.log_detail\">
	<zone_window>zone-$Service-log_detail</zone_window>
	<zone_on_click>--page zone.$Service.log_detail $Service.log_detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_position>zlogtail</zone_position>
	<zone_type>service_log</zone_type>
	<zone_status>$ServiceLogTailStatus</zone_status>
	<zone_html>$ServiceLogTail</zone_html>
<!-- end \"zone.$Service.log_detail\" --> </zone>"
	echo "$LogMapContent" >> $map_file
	;;
-mooc)
	MoocMapContent="
<zone name=\"zone.mooc.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$MoocZoneContent</zone_html>
<!-- end \"zone.mooc.zone\" --> </zone>"
	echo "$MoocMapContent" >> $map_file
	;;
-open_service)
	OpenServiceMapContent="
<zone name=\"zone.open_service.map\">
	<zone_window>zone-open_service_detail</zone_window>
	<zone_on_click>--page zone.open_service_detail open_service_detail.draw</zone_on_click>
	<zone_doc_over>open_service to be documented</zone_doc_over>
	<zone_position>zopen_service</zone_position>
	<zone_type>manage_service</zone_type>
	<zone_html><![CDATA[$OpenServiceMapContent]]></zone_html>
<!-- end \"zone.open_service.map\" --> </zone>"
	echo "$OpenServiceMapContent" >> $map_file
	;;
-page_back)
	PageBackContent="
<zone name=\"zone.pageback2.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$PageBack2</zone_html>
<!-- end \"zone.pageback2.zone\" --> </zone>"
	echo "$PageBackContent" >> $map_file
	;;
-page_top)
	PageTopContent="
<zone name=\"zone.pagetop.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$PageTop</zone_html>
<!-- end \"zone.pagetop.zone\" --> </zone>"
	echo "$PageTopContent" >> $map_file
	;;
-service)
	ServiceMapContent="
<zone name=\"zone.$Service.map\">
	<zone_position>zleft</zone_position>
<zone name=\"zone.$Service.name\">
	<zone_on_click>--page zone.$Service.map $Service.detail.draw</zone_on_click>
	<zone_doc_over>$ServiceDoc</zone_doc_over>
	<zone_type>service_name</zone_type>
	<zone_status>$ServiceStatus</zone_status>
	<zone_label><![CDATA[<img src=\"$ServiceImage\" alt=\"S \"/> $Service]]></zone_label>
<!-- end \"zone.$Service.name\" --> </zone>
<zone name=\"zone.$Service.running\">
	<zone_type>service_running</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_label>$ServiceRunning - role $ServiceRole</zone_label>
<!-- end \"zone.$Service.running\" --> </zone>
<zone name=\"zone.$Service.version\">
	<zone_type>service_version</zone_type>
	<zone_status>$ServiceStatus</zone_status>
	<zone_label>$ServiceErpName - $ServiceVersion</zone_label>
<!-- end \"zone.$Service.version.zone\" --> </zone>
<zone name=\"zone.$Service.url\">
	<zone_type>service_information</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_html>$ServiceLoginUrl</zone_html>
<!-- end \"zone.$Service.url\" --> </zone>
<zone name=\"zone.$Service.last_login\">
	<zone_type>service_last_login</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_html>$ServiceLastLogin</zone_html>
<!-- end \"zone.$Service.last_login\" --> </zone>
<zone name=\"zone.$Service.documentation\">
	<zone_type>service_information</zone_type>
	<zone_status>$ServiceRunningStatus</zone_status>
	<zone_html>$ServiceSummary</zone_html>
<!-- end \"zone.$Service.documentation\" --> </zone>
<!-- end \"zone.$Service.map\" --> </zone>"
	echo "$ServiceMapContent" >> $map_file
	;;
-system)
	SystemMapContent="
<zone name=\"zone.system.zone\">
	<zone_position>zwide</zone_position>
	<zone_html>$SystemZoneContent</zone_html>
<!-- end \"zone.system.zone\" --> </zone>"
	echo "$SystemMapContent" >> $map_file
	;;
esac
case "$1" in
-new_page)
	SHAPE_XML_FILE DRAW_MAP-$LINENO -end_page $4 $3
	;;
esac
}
#end DRAW_MAP
#------------------------------------------------------------------------------
DRAW_GLOBAL_ZONE_DETAIL ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g DRAW_GLOBAL_LOG_ZONE $*
SHAPE_XML_FILE DRAW_GLOBAL_LOG_ZONE-$LINENO $1 $3 $2
dglz_page_draw="$2"
GET_DATA -general_log
DRAW_MAP -continue -general_log $dglz_page_draw
DRAW_MAP -continue -page_top $dglz_page_draw
#if [ "${RefreshMode}" = "All" ] || echo "$DisplayedPages" | grep -q "^log_detail\." ; then
DRAW_DETAIL DRAW_GLOBAL_LOG_ZONE_$LINENO -init -general_log log_detail $DrawingCurrentDirectory/log_detail.draw
	# creer ServiceLogTailStatus ServiceLogTail Service.log_detail.draw
#fi
case "$1" in
#------------------------------------------------------------------------------
-new_page)
#------------------------------------------------------------------------------
	SHAPE_XML_FILE DRAW_GLOBAL_LOG_ZONE-$LINENO -end_page $3 $2
	;;
esac
}
#end DRAW_GLOBAL_LOG_ZONE
#------------------------------------------------------------------------------
DRAW_GLOBAL_LOG_ZONE ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g DRAW_GLOBAL_LOG_ZONE $*
SHAPE_XML_FILE DRAW_GLOBAL_LOG_ZONE-$LINENO $1 $3 $2
dglz_page_draw="$2"
GET_DATA -general_log
DRAW_MAP -continue -general_log $dglz_page_draw
DRAW_MAP -continue -page_top $dglz_page_draw
#if [ "${RefreshMode}" = "All" ] || echo "$DisplayedPages" | grep -q "^log_detail\." ; then
DRAW_DETAIL DRAW_GLOBAL_LOG_ZONE_$LINENO -init -general_log log_detail $DrawingCurrentDirectory/log_detail.draw
	# creer ServiceLogTailStatus ServiceLogTail Service.log_detail.draw
#fi
case "$1" in
#------------------------------------------------------------------------------
-new_page)
#------------------------------------------------------------------------------
	SHAPE_XML_FILE DRAW_GLOBAL_LOG_ZONE-$LINENO -end_page $3 $2
	;;
esac
}
#end DRAW_GLOBAL_LOG_ZONE
#------------------------------------------------------------------------------
DRAW_DASHBOARD_MENU ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g DRAW_DASHBOARD_MENU $*
#TR T_Service_List	Service list : Liste des services
menu_draw="$1"
echo "" > $menu_draw
for Service in $ServiceList ; do
	GET_DATA -summary
	echo "<a href=\"index.php?action=--page zone.${Service}.map ${Service}.draw\" title=\"$ServiceDoc\"><div class=\"menu_element\"><div class=\"$ServiceStatus\">$Service ($DatabaseNumber)</div></div></a>" >> $menu_draw
done
}
#end DRAW_DASHBOARD_MENU
#------------------------------------------------------------------------------
DRAW_ALL_SERVICE_DETAILS ()
#------------------------------------------------------------------------------
{
	dasd_call="$1-DRAW_ALL_SERVICE_DETAILS"
	#LOG_MESSAGE $LINENO -g DRAW_ALL_SERVICE_DETAILS $* $Service $DatabaseList

	for Database in $DatabaseList ; do
		GET_DATA -database
		if [ ${RefreshMode} = "All" ] || echo "$DisplayedPages" | grep -q "^$Service.$Database\." ; then
			DRAW_DETAIL $dasd_call-$LINENO -init -database_menu $Service.$Database.menu $DrawingCurrentDirectory/$Service.$Database.menu.draw
			DRAW_DETAIL $dasd_call-$LINENO -init -database $Service.$Database.info $DrawingCurrentDirectory/$Service.$Database.info.draw
			cat $DrawingCurrentDirectory/$Service.$Database.menu.draw > $DrawingCurrentDirectory/$Service.$Database.detail.draw
			cat $DrawingCurrentDirectory/$Service.$Database.info.draw >> $DrawingCurrentDirectory/$Service.$Database.detail.draw
			#echo "Concat to $DrawingCurrentDirectory/$Service.$Database.detail.draw on $Date mode $ServerMode parameters $dasd_call-$LINENO" >> $DrawingsLog
			#echo "$ServiceLogDetail ServiceLogDetail" | tail >> $DrawingsLog
		fi
	done
	if [ ${RefreshMode} = "All" ] || echo "$DisplayedPages" | grep -q "^$Service\." ; then
		DRAW_DETAIL $dasd_call-$LINENO -init -log zone.log $DrawingCurrentDirectory/$Service.log_detail.draw
		DRAW_DETAIL $dasd_call-$LINENO -init -instructions zone.instructions $DrawingCurrentDirectory/$Service.instructions_detail.draw
		DRAW_DETAIL $dasd_call-$LINENO -init -lastactions zone.lastactions $DrawingCurrentDirectory/$Service.lastactions_detail.draw
		DRAW_DETAIL $dasd_call-$LINENO -init -anomalies zone.anomalies $DrawingCurrentDirectory/$Service.anomalies_detail.draw
		DRAW_DETAIL $dasd_call-$LINENO -init -configuration zone.configuration $DrawingCurrentDirectory/$Service.configuration_detail.draw
		echo "Draw $DrawingCurrentDirectory/$Service.log_detail.draw on $Date mode $ServerMode parameters $dasd_call-$LINENO" >> $DrawingsLog
	#	# creer ServiceLogTailStatus ServiceLogTail Service.log_detail.draw
	fi
	if [ ${RefreshMode} = "All" ] || echo "$DisplayedPages" | grep -q "^$Service\." ; then
		DRAW_DETAIL $dasd_call-$LINENO -init -service_menu $Service.menu $DrawingCurrentDirectory/$Service.menu.draw
		DRAW_DETAIL $dasd_call-$LINENO -init -service $Service.info $DrawingCurrentDirectory/$Service.info.draw
		cat $DrawingCurrentDirectory/$Service.menu.draw > $DrawingCurrentDirectory/$Service.detail.draw
		cat $DrawingCurrentDirectory/$Service.info.draw >> $DrawingCurrentDirectory/$Service.detail.draw
		echo "Concat to $DrawingCurrentDirectory/$Service.detail.draw on $Date mode $ServerMode parameters $dsz_call-$LINENO" >> $DrawingsLog
	fi
}
#------------------------------------------------------------------------------
DRAW_SERVICE_ZONE ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g DRAW_SERVICE_ZONE $* $Service $DatabaseList
#service pages are refreshed
#DRAW_SERVICE_ZONE comment -new_page|-continue comment target_file
dsz_call="$1-DRAW_SERVICE_ZONE"
shift
dsz_option=$1
dsz_comment="$2"
dsz_page_draw="$3"
SHAPE_XML_FILE $dsz_call-$LINENO $dsz_option $dsz_comment $dsz_page_draw
echo "
<zone name=\"zone.$Service.zone\">
	<zone_position>zwide</zone_position>
" >> $dsz_page_draw
DRAW_MAP -continue -service $dsz_page_draw
echo "
<zone name=\"zone.$Service.databases.zone\">
	<zone_position>zdatabases</zone_position>
" >> $dsz_page_draw
for Database in $DatabaseList ; do
	#LOG_MESSAGE $LINENO -g DRAW_SERVICE_ZONE Database $Database
	GET_DATA -database
	DRAW_MAP -continue -database $dsz_page_draw
done
echo "
<!-- end \"zone.$Service.databases.zone\" --> </zone>
" >> $dsz_page_draw
DRAW_MAP -continue -instructions $dsz_page_draw
DRAW_MAP -continue -lastactions $dsz_page_draw
DRAW_MAP -continue -anomalies $dsz_page_draw
DRAW_MAP -continue -log $dsz_page_draw
case "$1" in
#------------------------------------------------------------------------------
-new_page)
#------------------------------------------------------------------------------
	DRAW_MAP -continue -page_back $dsz_page_draw
	;;
#------------------------------------------------------------------------------
-continue)
#------------------------------------------------------------------------------
	DRAW_MAP -continue -page_top $dsz_page_draw
	;;
esac
echo "
<!-- end \"zone.$Service.zone\" --> </zone>
" >> $dsz_page_draw
case "$1" in
#------------------------------------------------------------------------------
-new_page)
#------------------------------------------------------------------------------
	SHAPE_XML_FILE $dsz_call-$LINENO -end_page $3 $2
	;;
#------------------------------------------------------------------------------
-continue)
#------------------------------------------------------------------------------
	;;
esac
}
#end DRAW_SERVICE_ZONE	
#------------------------------------------------------------------------------
DRAW_MAIN_PAGE ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g  DRAW_MAIN_PAGE $*
dmp_call="DRAW_MAIN_PAGE"
SHAPE_XML_FILE $dmp_call-$LINENO -new_page $DrawingCurrentDirectory/page.draw zone.page

GET_DATA -page
DRAW_DASHBOARD_MENU $GoeDir/goe.menu.draw
case "$ServerContractMode" in
show)
	GET_DATA -contract
	DRAW_MAP -continue -contract $DrawingCurrentDirectory/page.draw
	DRAW_DETAIL DRAW_CONTRACT_ZONE_$LINENO -init -contract contract_detail $DrawingCurrentDirectory/contract_detail.draw
	;;
esac
case "$AdminGuideMode" in
show)
	GET_DATA -admin_guide
	DRAW_MAP -continue -admin_guide $DrawingCurrentDirectory/page.draw
	DRAW_DETAIL DRAW_ADMIN_GUIDE_ZONE_$LINENO -init -admin_guide admin_guide_detail $DrawingCurrentDirectory/admin_guide_detail.draw
	;;
esac
case "$OpenServiceMode" in
show)
	GET_DATA -openservice
	DRAW_MAP -continue -open_service $DrawingCurrentDirectory/page.draw
	DRAW_DETAIL DRAW_OPEN_SERVICE_ZONE_$LINENO -init -open_service open_service_detail $DrawingCurrentDirectory/open_service_detail.draw
	;;
esac
case "$CloseServiceMode" in
show)
	GET_DATA -closeservice
	DRAW_MAP -continue -close_service $DrawingCurrentDirectory/page.draw
	DRAW_DETAIL DRAW_CLOSE_SERVICE_ZONE_$LINENO -init -close_service close_service_detail $DrawingCurrentDirectory/close_service_detail.draw
	;;
esac
case "$SystemInfoMode" in
show)
	GET_DATA -system
	DRAW_MAP -continue -system $DrawingCurrentDirectory/page.draw
	;;
esac
case "$MoocInfoMode" in
show)
	GET_DATA -mooc
	DRAW_MAP -continue -mooc $DrawingCurrentDirectory/page.draw
	;;
esac
case "$ServiceDetailsMode" in
show)
	for Service in $ServiceList ; do
		#LOG_MESSAGE $LINENO -g DRAW_MAIN_PAGE Service $Service
		GET_DATA -service
		DRAW_SERVICE_ZONE $LINENO -continue page.draw $DrawingCurrentDirectory/page.draw
		DRAW_SERVICE_ZONE $LINENO -new_page zone.page $DrawingCurrentDirectory/$Service.draw
		DRAW_ALL_SERVICE_DETAILS $LINENO
	done
	LANGUAGE $LINENO $Language
	;;
hide)
	for Service in $ServiceList ; do
		#LOG_MESSAGE $LINENO -g DRAW_MAIN_PAGE Service $Service
		GET_DATA -service
		DRAW_SERVICE_ZONE $LINENO -new_page zone.page $DrawingCurrentDirectory/$Service.draw
		DRAW_ALL_SERVICE_DETAILS $LINENO
	done
	LANGUAGE $LINENO $Language
	;;
esac
case "$ServerLogMode" in
show)
	DRAW_GLOBAL_LOG_ZONE -continue $DrawingCurrentDirectory/page.draw
	;;
esac
SHAPE_XML_FILE $dmp_call-$LINENO -end_page zone.page $DrawingCurrentDirectory/page.draw
}
#end DRAW_MAIN_PAGE	
#------------------------------------------------------------------------------
DRAW_DEFAULT ()
#------------------------------------------------------------------------------
{
	SHAPE_XML_FILE DRAW_DEFAULT-$LINENO -new_page zone.page $DrawingCurrentDirectory/page.draw

	#TR T_data_collect Collecting detailled information on the server : Collecte des informations detaillees sur le serveur
	#TR T_Search Searching : Recherche
	#TR T_available available : des actions
	#TR T_actions actions : disponibles
	#TR T_Analysing Analysing server status : Analyse en cours du serveur
	#TR T_Wait Please wait a little more : Merci d'attendre encore quelques secondes


	DefaultPageContent="<zone name=\"zone.default\">
	<zone_title><![CDATA[<title>$T_data_collect</title>]]></zone_title>

	<zone_label>$T_data_collect. $T_Wait....</zone_label>
<!-- end \"zone.default\" --> </zone>"

	if [ ! -z $XmlFile ] ; then
		echo "$DefaultPageContent" >> $XmlFile
	else
		echo "$DefaultPageContent"
	fi
	SHAPE_XML_FILE DRAW_MDEFAULT_PAGE-$LINENO -end_page zone.page $DrawingCurrentDirectory/page.draw
}
#end DRAW_DEFAULT
#------------------------------------------------------------------------------
DRAW_ERROR ()
#------------------------------------------------------------------------------
{
	#A finaliser pour une page d'erreur avec un bouton de redemarrage du service en erreur
	SHAPE_XML_FILE DRAW_DEFAULT-$LINENO -new_page zone.page $DrawingCurrentDirectory/page.draw

	#TR T_data_is_wrong Collected information cannot be displayed : Les informations collectees ne peuvent pas etre presentees
	#TR T_Search Searching : Recherche
	#TR T_available available : des actions
	#TR T_actions actions : disponibles
	#TR T_Analysing Analysing server status : Analyse en cours du serveur
	#TR T_Must_restart A service must probably be restarted : Un service doit probablement etre redemarre


	ErrorPageContent="<zone name=\"zone.default\">
	<zone_title><![CDATA[<title>$T_data_is_wrong</title>]]></zone_title>

	<zone_label>$T_data_is_wrong. $T_Must_restart....</zone_label>
<!-- end \"zone.default\" --> </zone>"

	if [ ! -z $XmlFile ] ; then
		echo "$ErrorPageContent" >> $XmlFile
	else
		echo "$ErrorPageContent"
	fi
	SHAPE_XML_FILE DRAW_DEFAULT_PAGE-$LINENO -end_page zone.page $DrawingCurrentDirectory/page.draw
}
#end DRAW_ERROR
#------------------------------------------------------------------------------
DRAW_MAIN_PAGE_NOW ()
#------------------------------------------------------------------------------
{
LOG_MESSAGE $LINENO -g  DRAW_MAIN_PAGE_NOW $*

if [ ! -z "$1" ] ; then
	ServiceList="$1"
	GET_DATA -service
	DRAW_SERVICE_ZONE $LINENO -new_page zone.page $DrawingCurrentDirectory/$Service.draw
	LANGUAGE $LINENO $Language
else
	SHAPE_XML_FILE DRAW_MAIN_PAGE_NOW-$LINENO -new_page zone.page $DrawingCurrentDirectory/page.draw 
	GET_DATA -page

	DRAW_DASHBOARD_MENU $GoeDir/goe.menu.draw

	case "$ServerContractMode" in
	show)
		GET_DATA -contract
		DRAW_MAP -continue -contract $DrawingCurrentDirectory/page.draw
		DRAW_DETAIL DRAW_CONTRACT_ZONE_$LINENO -init -contract contract_detail $DrawingCurrentDirectory/contract_detail.draw
		;;
	esac
	case "$AdminGuideMode" in
	show)
		GET_DATA -admin_guide
		DRAW_MAP -continue -admin_guide $DrawingCurrentDirectory/page.draw
		DRAW_DETAIL DRAW_ADMIN_GUIDE_ZONE_$LINENO -init -admin_guide admin_guide_detail $DrawingCurrentDirectory/admin_guide_detail.draw
		;;
	esac

	case "$OpenServiceMode" in
	show)
		GET_DATA -openservice
		DRAW_MAP -continue -open_service $DrawingCurrentDirectory/page.draw
		DRAW_DETAIL DRAW_OPEN_SERVICE_ZONE_$LINENO -init -open_service open_service_detail $DrawingCurrentDirectory/open_service_detail.draw
		;;
	esac
	case "$CloseServiceMode" in
	show)
		GET_DATA -closeservice
		DRAW_MAP -continue -close_service $DrawingCurrentDirectory/page.draw
		DRAW_DETAIL DRAW_CLOSE_SERVICE_ZONE_$LINENO -init -close_service close_service_detail $DrawingCurrentDirectory/close_service_detail.draw
		;;
	esac
	case "$SystemInfoMode" in
	show)
		GET_DATA -system
		DRAW_MAP -continue -system $DrawingCurrentDirectory/page.draw
		;;
	esac
	case "$MoocInfoMode" in
	show)
		GET_DATA -mooc
		DRAW_MAP -continue -mooc $DrawingCurrentDirectory/page.draw
		;;
	esac
	case "$ServiceDetailsMode" in
	show)
		for Service in $ServiceList ; do
			#LOG_MESSAGE $LINENO -g DRAW_MAIN_PAGE_NOW Service $Service
			GET_DATA -service
			DRAW_SERVICE_ZONE $LINENO -continue page $DrawingCurrentDirectory/page.draw
		done
		LANGUAGE $LINENO $Language
		;;
	esac
	case "$ServerLogMode" in
	show)
		DRAW_GLOBAL_LOG_ZONE -continue $DrawingCurrentDirectory/page.draw
		;;
	esac
	SHAPE_XML_FILE DRAW_MAIN_PAGE_NOW-$LINENO -end_page zone.page $DrawingCurrentDirectory/page.draw
fi
}
#end DRAW_MAIN_PAGE_NOW
#------------------------------------------------------------------------------
CHECK_XML ()
#------------------------------------------------------------------------------
{
if xmlstarlet --version > /dev/null 2>&1 ; then
	cd $1
	XmlFileList=`ls *.draw`
	for XmlFile in $XmlFileList ; do
		case "$XmlFile" in
		menu.draw|*.menu.draw|*.info.draw)
			;;
		*)
			XmlFileStatus=`xmlstarlet val $XmlFile`
			case "$XmlFileStatus" in
			*invalid)
				LOG_MESSAGE $LINENO -g  XML file $XmlFile is broken $XmlFileStatus
				echo "#file $XmlFile is broken $XmlFileStatus" >> /tmp/goe.broken_xml
				cat $XmlFile >> /tmp/goe.broken_xml
				;;
			esac
			;;
		esac
	done
fi
}
#end CHECK_XML
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
	case "$Option" in
	--draw)
		#LOG_MESSAGE $LINENO -g execution --draw to draw zone.page page.draw
		DrawingCurrentDirectory="$Drawings.draft"
		if [ -d "$DrawingCurrentDirectory" ] ; then  rm -rf $DrawingCurrentDirectory ; fi
		mkdir $DrawingCurrentDirectory
		chmod 770 $DrawingCurrentDirectory
		echo "Start drawing batch $Option on $Date" >> $DrawingsLog
		DRAW_DETAIL draw_$LINENO -init -default default.detail $DrawingCurrentDirectory/default.detail.draw
		DisplayedPages=`tail -n $PageHistory $PageLog`
		if [ -f $SiteRefreshModeFile ] ; then
			RefreshMode=`cat $SiteRefreshModeFile`
		fi
		LOG_MESSAGE $LINENO -g execution --draw, refresh mode is $RefreshMode, recently displayed pages are `echo "$DisplayedPages" | sort -u | xargs`
		DRAW_MAIN_PAGE
		CHECK_XML $DrawingCurrentDirectory
		chmod 770 $DrawingCurrentDirectory/*
		#LOG_MESSAGE $LINENO -g execution --draw `ls -lhR $DrawingCurrentDirectory`
		$Sudo chown $XoeAuthorizedUser:$HttpUser $DrawingCurrentDirectory
		CHECK_BUZY $LINENO set
		#mv $Drawings $Drawings.removed
		mv $DrawingCurrentDirectory/* $Drawings
		CHECK_BUZY $LINENO release
		LOG_MESSAGE $LINENO -g --draw fresh page contents have been updated

		echo "End drawing batch $Option on $Date" >> $DrawingsLog
		#rm -rf $Drawings.removed
		#echo ".... `date +'%Hh%Mm%Ss:%3N'`" >> $GoeDir/goe.draw.log
		;;
	--draw_default)

		DrawingCurrentDirectory="$Drawings.draft"
		if [ -d "$DrawingCurrentDirectory" ] ; then  rm -rf $DrawingCurrentDirectory ; fi
		mkdir $DrawingCurrentDirectory
		#echo "Start Default drawing batch $Option on $Date" >> $DrawingsLog
		DRAW_DEFAULT -init -default $DrawingCurrentDirectory/page.draw
		chmod -R 770 $DrawingCurrentDirectory
		#LOG_MESSAGE $LINENO -g execution --draw_default `ls -lhR $DrawingCurrentDirectory`
		$Sudo chown $XoeAuthorizedUser:$HttpUser $DrawingCurrentDirectory
		CHECK_BUZY $LINENO set
		#mv $Drawings $Drawings.removed
		mv $DrawingCurrentDirectory/* $Drawings
		CHECK_BUZY $LINENO release
		LOG_MESSAGE $LINENO -g --draw_default no activity default page content has been set
		#rm -rf $Drawings.removed
		#echo "End Default drawing batch $Option on $Date" >> $DrawingsLog
		;;
	#------------------------------------------------------------------------------
	--draw_now)
	#------------------------------------------------------------------------------
		LOG_MESSAGE $LINENO -g --draw_now draw on the fly a missing page with zone $ZoneName and drawing $Drawing
		#echo -n "draw_now    `date +'%Hh%Mm%Ss:%3N'` ...." >> $GoeDir/goe.draw.log
		echo "Start drawing on demand $Option $Drawing on $Date" >> $DrawingsLog
		DrawingCurrentDirectory="$Drawings"
		if [ -f $SiteRefreshModeFile ] ; then
			RefreshMode="Now"
		fi
		DRAWING_TO_SERVICE $Drawing
		#LOG_MESSAGE $LINENO -g execution --draw_now Service $Service Database $Database to calculate $Drawing
		case "$Drawing" in
		log_detail.draw)
			#draw global log
			DRAW_DETAIL draw_now_$LINENO -init -general_log general_log
			;;
		*.log_detail.draw|*.instructions_detail.draw|*.configuration_detail.draw)
			#draw service log
			GET_DATA -service
			DRAW_DETAIL draw_now_$LINENO -init -log zone.log
			DRAW_DETAIL draw_now_$LINENO -init -instructions zone.instructions
			DRAW_DETAIL draw_now_$LINENO -init -lastactions zone.lastactions
			DRAW_DETAIL draw_now_$LINENO -init -anomalies zone.anomalies
			DRAW_DETAIL draw_now_$LINENO -init -configuration zone.configuration
			LANGUAGE $LINENO $Language
			;;
		*detail.draw)
			if [ ! -z "$Database" ] ; then
				LOG_MESSAGE $LINENO -g --draw_now draw page Database $Database
				GET_DATA -service
				GET_DATA -database
				DRAW_DETAIL draw_now_$LINENO -init -database_menu $Service.$Database.menu $DrawingCurrentDirectory/$Service.$Database.menu.draw
				DRAW_DETAIL draw_now_$LINENO -init -database $Service.$Database.info $DrawingCurrentDirectory/$Service.$Database.info.draw
				cat $DrawingCurrentDirectory/$Service.$Database.menu.draw > $DrawingCurrentDirectory/$Service.$Database.detail.draw
				cat $DrawingCurrentDirectory/$Service.$Database.info.draw >> $DrawingCurrentDirectory/$Service.$Database.detail.draw
				cat $DrawingCurrentDirectory/$Service.$Database.menu.draw
				cat $DrawingCurrentDirectory/$Service.$Database.info.draw
				LANGUAGE $LINENO $Language
			else
				if [ ! -z "$Service" ] ; then
					LOG_MESSAGE $LINENO -g --draw_now draw page Service $Service
					GET_DATA -service
					DRAW_DETAIL draw_now_$LINENO -init -service_menu $Service.menu $DrawingCurrentDirectory/$Service.menu.draw
					DRAW_DETAIL draw_now_$LINENO -init -service $Service.info $DrawingCurrentDirectory/$Service.info.draw
					cat $DrawingCurrentDirectory/$Service.menu.draw > $DrawingCurrentDirectory/$Service.detail.draw
					cat $DrawingCurrentDirectory/$Service.info.draw >> $DrawingCurrentDirectory/$Service.detail.draw
					cat $DrawingCurrentDirectory/$Service.menu.draw
					cat $DrawingCurrentDirectory/$Service.info.draw
					LANGUAGE $LINENO $Language
				else
					if [ -f $DrawingCurrentDirectory/default.detail.draw ] ; then
						cat $DrawingCurrentDirectory/default.detail.draw
						LOG_MESSAGE $LINENO -g "looking for default page $DrawingCurrentDirectory/$DrawingName, serving $DrawingCurrentDirectory/default.detail.draw instead"
					else
						LOG_MESSAGE $LINENO 404 exit "looking for missing $DrawingCurrentDirectory/$DrawingName, and no default page is available"
					fi
				fi
			fi
			;;
		page.draw)
			#draw all services map
			#LOG_MESSAGE $LINENO -g --draw_now zone.page page.draw
			DRAW_MAIN_PAGE_NOW
			$Sudo chown $XoeAuthorizedUser:$HttpUser $DrawingCurrentDirectory/$Service.draw
			cat $DrawingCurrentDirectory/page.draw
			;;
		*.draw)
			#draw service map
			#LOG_MESSAGE $LINENO -g --draw_now zone.$Service $Service.draw
			DRAW_MAIN_PAGE_NOW $Service
			$Sudo chown $XoeAuthorizedUser:$HttpUser $DrawingCurrentDirectory/$Service.draw
			cat $DrawingCurrentDirectory/$Service.draw
			;;
		*)
			LOG_MESSAGE $LINENO -g --draw_now unexpected case $Zonename $Drawing
			;;
		esac
		LOG_MESSAGE $LINENO -g --draw_now  missing page have been drawn with zone $ZoneName and drawing $Drawing
		#echo ".... `date +'%Hh%Mm%Ss:%3N'`" >> $GoeDir/goe.draw.log
		echo "End drawing on demand $Option on $Date" >> $DrawingsLog
		;;
	esac
	;;
#------------------------------------------------------------------------------
--collect)

#------------------------------------------------------------------------------
COLLECT_DATA ()
#------------------------------------------------------------------------------
{
#LOG_MESSAGE $LINENO -g COLLECT_DATA $* Mode $ServerMode
#TR T_Running Running : Marche
#TR T_Stopped Stopped : Arret
cd $GoeData

UPDATE_DATA_FILE ()
{
chmod 770 $1.draft
$Sudo chown -R $XoeAuthorizedUser:$HttpUser $1.draft
mv $1.draft $1
echo -n "$2" >> data.log
}
data_type="$1"
case "$data_type" in
page)
	#ServiceData=`cat $XoeServicesData | grep -v "^#" | grep -v "^ServiceList=" | grep -v "^ServiceNumber=" | grep -v "^return" | sort`
	GET_XOE_DATA
	#ServiceList=`cat $XoeServicesData 2>/dev/null | grep -m 1 "^ServiceList=" | cut -d"=" -f2- | sed s'/ /\n/g' | sort | xargs`
	#ServiceData=`cat $XoeServicesData | grep "^#Service:" | grep "ServiceErpName=\|ServiceVersion=" | sort`
	#LOG_MESSAGE $LINENO -g COLLECT_DATA ServiceList $ServiceList
	echo "ServiceList=\"$ServiceList\"" > ServiceList.data.draft
	#echo "ServiceData=\"$ServiceData\"" >> ServiceList.data.draft
	UPDATE_DATA_FILE ServiceList.data p
	#LOG_MESSAGE $LINENO -g COLLECT_DATA ServiceList $ServiceList
	;;
contract)
	case "$ServerContractMode" in
	show)
		#TR T_Contract_manager Contract administration : Evolution du contrat
		#TR T_No_Contract	Contract management function is not available : La gestion du contrat n est pas disponible
		ContractFile="$XoeDir/xoe.packages/subscription.documentation"
		ContractTitle="<div class=\\\"page_zone_title\\\">$T_Contract_manager</div>"
		if [ -f $ContractFile ] ; then
			ContractZoneContent="$ContractTitle
`cat $ContractFile | sed 's/\"//g' | sed 's/.*/& <br\/>/'`"
		else
			ContractZoneContent="$ContractTitle
Contract mgt"
		fi
		echo "ContractZoneContent=\"$ContractZoneContent\"" > contract.data.draft
		UPDATE_DATA_FILE contract.data b
		;;
	esac
	;;
admin_guide)
	case "$AdminGuideMode" in
	show)
		#TR T_Admin_guide Server administration : Administration du serveur
		#TR T_No_Guide	Administration documentation is not available : La documentation d administration n est pas disponible
		AdminGuideFile="$XoeDir/xoe.packages/admin_guide.documentation"
		AdminGuideTitle="<div class=\\\"page_zone_title\\\">$T_Admin_guide</div>"
		if [ -f $AdminGuideFile ] ; then
			AdminGuideZoneContent="$AdminGuideTitle
`cat $AdminGuideFile | sed 's/\"//g' | sed 's/.*/& <br\/>/'`"
		else
			AdminGuideZoneContent="$AdminGuideTitle
Next : admin guide"
		fi
		echo "AdminGuideZoneContent=\"$AdminGuideZoneContent\"" > admin_guide.data.draft
		UPDATE_DATA_FILE admin_guide.data a
		;;
	esac
	;;
openservice)
	case "$OpenServiceMode" in
	show)
		#TR T_Form_new_service Form_to_create a new service ; Formulaire pour creer un nouveau service
		#TR T_Open_Service Open a new service : Ouverture d un nouveau service
		#TR T_No_Open_Service	Open function is not available : L ouverture de service n est pas disponible
		#TR T_Service_prefix	Prefix to the name of new service : Prefixe du nom du service
		#TR T_Warning_new_service If service already exists, this may damage its configuration : Si le service existe deja, sa configuration peut etre endommagee
		#TR T_Link	Go to new service declaration form... : Acceder au formulaire de declaration...
		#TR T_OpenServiceDefaults	These are configured default values : Voici les valeurs par defaut configurees
		if [ ! -f $OpenServiceDocumentation ] ; then
			cd $XoeDir/xoe.packages
			wget http://download.sisalp.net/lorem
		fi
		OpenServiceTitle="<div class=\\\"page_zone_title\\\">$T_Open_Service</div>"
		if [ ! -z "$OpenServiceDocumentation" ] ; then
			OpenServiceDocumentation="No documentation"
		fi
		OpenServiceLink="<br/><div class=\\\"link_element\\\"><div class=\\\"static\\\"> $T_Link <br/></div></div><br/>"
		OpenServiceDocumentation="<br/>`cat $XoeDir/xoe.packages/open_service.documentation | sed 's/\"//g' | sed 's/.*/& <br\/>/'`"
		OpenServiceDefaultsTitle="$T_OpenServiceDefaults :<br/>-------------------------<br/>"
		OpenServiceDefaults=`cat $XoeServicesData | grep ^DEF_  | sed 's/\"//g' | sed 's/.*/& <br\/>/'`
		if [ ! -z "$DEF_service_trailing_name" ] ; then
			postfix="-$DEF_service_trailing_name"
		fi
		def_prefix=`NEW_PASSWORD -letters 4`
		OpenServiceForm="
<div id=\\\"zonenewservice_form\\\"><div class=\\\"dashboard_form\\\"><form method=POST enctype=\\\"multipart/form-data\\\" action=\\\"index.php?action=--on_click zone.open_service_detail open_service_detail.draw goe --dashboard newservice\\\"> $T_Form_new_service<br/>
 $T_Open_Service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"prefix company month period\\\">
<br/><br/>
<table>
<tr><td> $T_Service_prefix : </td><td><input type=\\\"text\\\" name=\\\"prefix\\\" value=\\\"$def_prefix\\\" style=\\\"cursor:pointer; width:300px; padding:3px 20px; margin: 3px; background-color: #eeeeee; border:solid 1px #999999;\\\" required >$postfix</td></tr>
<tr><td> $T_Company_name : </td><td><input type=\\\"text\\\" name=\\\"company\\\" value=\\\" Ma Societe\\\" style=\\\"cursor:pointer; width:300px; padding:3px 20px; margin: 3px; background-color: #eeeeee; border:solid 1px #999999;\\\" required ></td></tr>
<tr><td> $T_Choose_month : </td><td><select name=\\\"month\\\" style=\\\"cursor:pointer; width:300px; padding:3px 20px; margin: 3px; background-color: #eeeeee; border:solid 1px #999999;\\\" required><option value=\\\"1\\\"> $T_january</option>
<option value=\\\"2\\\"> $T_february</option>
<option value=\\\"3\\\"> $T_march</option>
<option value=\\\"4\\\"> $T_april</option>
<option value=\\\"5\\\"> $T_may</option>
<option value=\\\"6\\\"> $T_june</option>
<option value=\\\"7\\\"> $T_july</option>
<option value=\\\"8\\\"> $T_august</option>
<option value=\\\"9\\\"> $T_september</option>
<option value=\\\"10\\\"> $T_october</option>
<option value=\\\"11\\\"> $T_november</option>
<option value=\\\"12\\\"> $T_december</option></select></td></tr>
<tr><td> $T_Choose_period :  </td><td><input type=\\\"radio\\\" name=\\\"period\\\" value=\\\"1\\\" checked>  $T_monthly</td></tr>
<tr><td></td><td><input type=\\\"radio\\\" name=\\\"period\\\" value=\\\"3\\\" >  $T_quarterly</td></tr>
</table>
 $T_Warning :  $T_Warning_new_service.<br/>
<br/><input type=\\\"submit\\\" name =\\\"validate\\\" value=\\\"Valider\\\"/></form></div></div>"
		OpenServiceForm="

<div id=\\\"zonenewservice_form\\\"><div class=\\\"dashboard_form\\\"><form method=POST enctype=\\\"multipart/form-data\\\" action=\\\"index.php?action=--on_click zone.open_service_detail open_service_detail.draw goe --dashboard newservice\\\"> Formulaire pour creer un nouveau service<br/>
 Creer un nouveau service<br/>
<input type=\\\"hidden\\\" name=\\\"fields\\\" value=\\\"prefix\\\">
<br/>
<table>
<tr><td> Prefixe du service : </td><td><input type=\\\"text\\\" name=\\\"prefix\\\" value=\\\"$def_prefix\\\" style=\\\"cursor:pointer; width:300px; padding:3px 20px; margin: 3px; background-color: #eeeeee; border:solid 1px #999999;\\\" required >$postfix</td></tr>
</table>
 $T_Warning :  $T_Warning_new_service.<br/>
<br/><input type=\\\"submit\\\" name =\\\"validate\\\" value=\\\"Valider\\\"/></form></div></div>"

		OpenServiceMapContent="
$OpenServiceTitle
$OpenServiceLink
$OpenServiceDocumentation
$OpenServiceDefaultsTitle
$OpenServiceDefaults"

		OpenServiceZoneContent="
$OpenServiceTitle
$OpenServiceDocumentation
$OpenServiceDefaultsTitle
$OpenServiceDefaults
$OpenServiceForm"
		echo "OpenServiceMapContent=\"$OpenServiceMapContent\"" > openservice.data.draft
		echo "OpenServiceZoneContent=\"$OpenServiceZoneContent\"" >> openservice.data.draft
		UPDATE_DATA_FILE openservice.data o
		;;
	esac
	;;
closeservice)
	case "$CloseServiceMode" in
	show)
		#TR T_Close_Service Close a service : Cloture d un service
		#TR T_No_Close_Service	Close function is not available : La cloture de service n est pas disponible
		CloseServiceFile="$XoeDir/xoe.packages/close_service.documentation"
		CloseServiceTitle="<div class=\\\"page_zone_title\\\">$T_Close_Service</div>"
		if [ ! -f $CloseServiceFile ] ; then
			cd $XoeDir/xoe.packages
			wget http://download.sisalp.net/lorem
		fi
		CloseServiceZoneContent="$CloseServiceTitle
`cat $CloseServiceFile | sed 's/\"//g' | sed 's/.*/& <br\/>/'`"
		echo "CloseServiceZoneContent=\"$CloseServiceZoneContent\"" > closeservice.data.draft
		UPDATE_DATA_FILE closeservice.data c
		;;
	esac
	;;
system)
	case "$SystemInfoMode" in
	show)
		BAR_STATUS () { bst="low" ; if [ $1 -gt 75 ] ; then bst="medium" ; fi ; if [ $1 -ge 88 ] ; then bst="high" ; fi ; echo "$bst" ; }
		CPU () { SystemUserCpu="$2" ; SystemNiceCpu="$3" ; SystemSysCpu="$4" ; SystemIdleCpu="$5" ; SystemIowaitCpu="$6" ;  SystemIrqCpu="$7" ;  SystemSoftirqCpu="$8" ; }
		CPU `cat /proc/stat 2>/dev/null | grep -m 1 "^cpu" | xargs`
		NewSystemUsedCpu=`echo "$SystemUserCpu + $SystemNiceCpu + $SystemSysCpu + $SystemIowaitCpu + $SystemIrqCpu + $SystemSoftirqCpu" | bc`
		NewSystemTotalCpu=`echo "$NewSystemUsedCpu + $SystemIdleCpu " | bc `
		if [ -f $GoeDir/goe.system_cpu.data ] ; then
			CPU_PREVIOUS () { OldSystemUsedCpu="$1" ; OldSystemTotalCpu="$2" ; }
			CPU_PREVIOUS `cat $GoeDir/goe.system_cpu.data | xargs`
		else
			OldSystemUsedCpu=0
			OldSystemTotalCpu=0
		fi
		SystemUsedCpu=`echo "$NewSystemUsedCpu - $OldSystemUsedCpu" | bc `
		SystemTotalCpu=`echo "$NewSystemTotalCpu - $OldSystemTotalCpu" | bc `
		SystemPercentCpu=`echo "$SystemUsedCpu * 100 / $SystemTotalCpu" | bc`
		SystemStatusCpu=`BAR_STATUS $SystemPercentCpu`
		echo "$NewSystemUsedCpu $NewSystemTotalCpu $SystemPercentCpu $OldSystemUsedCpu $OldSystemTotalCpu" > $GoeDir/goe.system_cpu.data
		SystemNumberCpu=`cat /proc/stat | grep -i "^cpu" | grep -vi "^cpu0" | wc -l`
		MemTotal=`cat /proc/meminfo | grep ^MemTotal: | xargs | cut -d" " -f2`
		MemFree=`cat /proc/meminfo | grep ^MemFree: | xargs | cut -d" " -f2`
		MemUsed=`echo "$MemTotal - $MemFree" | bc`
		SystemTotalMemory=`echo "$MemTotal / 1024" | bc`
		SystemUsedMemory=`echo "$MemUsed / 1024" | bc`
		SystemPercentMemory=`echo "$SystemUsedMemory * 100 / $SystemTotalMemory" | bc`
		SystemStatusMemory=`BAR_STATUS $SystemPercentMemory`
		SWAP () { SwapTotal="$3" ; SwapUsed="$4" ; }
		SWAP `cat /proc/swaps | grep -v "Filename" | head -n 1 | xargs`
		SystemTotalSwap=`echo "$SwapTotal /1024" | bc`
		SystemUsedSwap=`echo "$SwapUsed /1024" | bc`
		#LOG_MESSAGE $LINENO -g COLLECT_DATA system MemTotal $MemTotal MemFree $MemFree MemUsed $MemUsed SystemTotalMemory $SystemTotalMemory SystemUsedMemory $SystemUsedMemory SwapTotal $SwapTotal SwapUsed $SwapUsed SystemTotalSwap $SystemTotalSwap SystemUsedSwap $SystemUsedSwap
		case "$SystemTotalSwap" in
		0)
			SystemPercentSwap="0"
			SystemZoneSwap=""
			;;
		*)
			SystemPercentSwap=`echo "$SystemUsedSwap * 100 / $SystemTotalSwap" | bc`
			SystemStatusSwap=`BAR_STATUS $SystemPercentSwap`
			SystemZoneSwap=""
			#SystemZoneSwap="<tr><td width=\\\"100\\\">$T_Swap</td><td class=\\\"bar_$SystemStatusSwap\\\"><div style=\\\"width: $SystemPercentSwap%\\\"></div></td><td>${SystemUsedSwap}/${SystemTotalSwap}M</td></tr>"
			;;
		esac
		TotalWorkingProcess=`ps axo args`
		PostgresProcess=`echo "$TotalWorkingProcess" | grep "^postgres: " | wc -l`
		PostgresConnections=`echo "$PostgresProcess - 3" | bc`
		if [ $PostgresConnections -le 0 ] ; then PostgresConnections="1" ; fi
		MaxPostgresConnections=`cat /etc/postgresql/*/main/postgresql.conf | grep "^max_connections = " | cut -d" " -f3`
		SystemPercentPostgres=`echo "$PostgresConnections * 100 / $MaxPostgresConnections" | bc`
		SystemStatusPostgres=`BAR_STATUS $SystemPercentPostgres`
		DISK ()
{
GB_SystemTotalDisk="$2"
SystemTotalDisk="${GB_SystemTotalDisk}G"
SystemUsedDisk="$3"
MB_SystemUsedDisk="$4"
MB_SystemTotalDisk=`echo "$GB_SystemTotalDisk * 1024" | bc`
SystemPercentDisk=`echo "$MB_SystemUsedDisk * 100 / $MB_SystemTotalDisk" | bc`
}
#end 
		if [ -f /I_AM_$HOSTNAME ] && cat /I_AM_$HOSTNAME | grep -q "^used_disk " ; then
			DISK `cat /I_AM_$HOSTNAME | grep "^used_disk " | xargs`
		else
			DISK used_disk_is_unknown 1 "`cat /I_AM_$HOSTNAME | grep ^used_disk  | xargs`" O
		fi
		SystemStatusDisk=`BAR_STATUS $SystemPercentDisk`
		if [ -f $GoeDir/goe.pace_time.conf ] ; then
			PaceTime=`cat $GoeDir/goe.pace_time.conf`
		else
			PaceTime=""
		fi
		#TR T_Server_status Server status : Etat du serveur
		#TR T_Processor Processor : Processeur
		#TR T_Memory Memory : Memoire
		#TR T_Swap Swap : Virtuelle
		#TR T_Postgresql Connections : Connexions
		#TR T_Disk Disk : Disque
		#TR T_Calculated_on Calculated at : Calcule a
		SystemZoneContent="<![CDATA[<table class=\\\"graph\\\" cellspacing=\\\"6\\\" cellpadding=\\\"0\\\">
<thead><tr><th colspan=\\\"3\\\">$T_Server_status</th></tr></thead>
<tbody>
<tr><td width=\\\"100\\\">$T_Processor</td><td  class=\\\"bar_$SystemStatusCpu\\\"><div style=\\\"width: $SystemPercentCpu%\\\"></div></td><td>$SystemPercentCpu% / $SystemNumberCpu CPUs</td></tr>
<tr><td width=\\\"100\\\">$T_Memory</td><td class=\\\"bar_$SystemStatusMemory\\\"><div style=\\\"width: $SystemPercentMemory%\\\"></div></td><td>${SystemUsedMemory}/${SystemTotalMemory}M</td></tr>
<tr><td width=\\\"100\\\">$T_Postgresql</td><td class=\\\"bar_$SystemStatusPostgres\\\"><div style=\\\"width: $SystemPercentPostgres%\\\"></div></td><td>$PostgresConnections / $MaxPostgresConnections </td></tr>
<tr><td width=\\\"100\\\">$T_Disk</td><td class=\\\"bar_$SystemStatusDisk\\\"><div style=\\\"width: $SystemPercentDisk%\\\"></div></td><td>$SystemUsedDisk / $SystemTotalDisk </td></tr>
</tbody>
<tfoot><tr><td colspan=\\\"3\\\">$T_Calculated_on `date +%H:%M:%S`. $PaceTime.</td></tr></tfoot>
</table>]]>"
		echo "SystemPercentCpu=\"$SystemPercentCpu\"" > system.data.draft
		echo "SystemNumberCpu=\"$SystemNumberCpu\"" >> system.data.draft
		echo "SystemUsedMemory=\"$SystemUsedMemory\"" >> system.data.draft
		echo "SystemTotalMemory=\"$SystemTotalMemory\"" >> system.data.draft
		echo "SystemPercentMemory=\"$SystemPercentMemory\"" >> system.data.draft
		echo "SystemUsedSwap=\"$SystemUsedSwap\"" >> system.data.draft
		echo "SystemTotalSwap=\"$SystemTotalSwap\"" >> system.data.draft
		echo "SystemPercentSwap=\"$SystemPercentSwap\"" >> system.data.draft
		echo "PostgresConnections=\"$PostgresConnections\"" >> system.data.draft
		echo "MaxPostgresConnections=\"$MaxPostgresConnections\"" >> system.data.draft
		echo "SystemPercentPostgres=\"$SystemPercentPostgres\"" >> system.data.draft
		echo "SystemUsedDisk=\"$SystemUsedDisk\"" >> system.data.draft
		echo "SystemTotalDisk=\"$SystemTotalDisk\"" >> system.data.draft
		echo "SystemPercentDisk=\"$SystemPercentDisk\"" >> system.data.draft
		echo "SystemZoneContent=\"$SystemZoneContent\"" >> system.data.draft
		UPDATE_DATA_FILE system.data c
		;;
	esac
	;;
mooc)
	case "$MoocInfoMode" in
	show)
		#TR T_Mooc_status Courses status : Cours crees
		#TR T_No_mooc	No courses has been created yet : Aucun cours n'a encore ete cree
		MoocList=""
		if [ -f /usr/local/bin/mooc ] ; then
			MoocList=`/usr/local/bin/mooc --list`
			MoocZoneContent=`/usr/local/bin/mooc --html`
		fi
		echo "MoocList=\"$MoocList\"" > mooc.data.draft
		echo "MoocZoneContent=\"$MoocZoneContent\"" >> mooc.data.draft
		UPDATE_DATA_FILE mooc.data m
		;;
	esac
	;;
service)
	#LOG_MESSAGE $LINENO -g "Acquisition du service $Service"
	GET_XOE_DATA $Service
	if [ -z "$ServiceLanguage" ] ; then
		ServiceLanguage="$Language"
	fi
	LANGUAGE $LINENO $ServiceLanguage

##
	#ServiceCompatibilityList=`/usr/local/bin/xoe --contract -compatible $Service`
	#LOG_MESSAGE $LINENO -g "Acquisition ServiceCompatibilityList du service $Service : $ServiceCompatibilityList"
	#ServiceVersion=`xoe --service -version $Service`
	#if [ -f "$XoeDir/xoe.services/$Service/version/service-$Service.version" ] ; then
	#	ServiceVersion=`cat $XoeDir/xoe.services/$Service/version/service-$Service.version`
	#	ServiceVersionDoc="les bases utilisees doivent etre compatibles avec la version $ServiceVersion"
	#	ServiceVersionStatus="ok"
	#else
	#	ServiceVersion="I don t know"
	#	ServiceVersionDoc="le service $Service n'est pas operationnel"
	#	ServiceVersionStatus="fault"
	#fi
	case "$Enabled_Buttons" in
	*-*)
		#remove space if list is empty
		ServiceButtons=`echo "$Enabled_Buttons" | cut -d- -f1 | xargs`
		;;
	*)
		ServiceButtons=`echo "$Available_Buttons" | cut -d- -f1 | xargs`
		;;
	esac
	if [ -z "$ServiceButtons" ] ; then
		case "$ServiceRole" in
		*production)
			ServiceButtons=`echo "$RestrictedButtonsList" | cut -d- -f1 | xargs`
			;;
		*)
			ServiceButtons="$ServiceButtonsDefaultList"
			;;
		esac
	fi
	#echo "ServiceButtons: $ServiceButtons" >> /tmp/ServiceButtons.$Service
	#TestRunning=`/usr/local/bin/xoe --watch -up -noblabla $Service`
	case "$TestRunning" in
	RUNNING)

	#if [ -f "$XoeDir/xoe.services/$Service/pid_file/server_$Service.pid" ] && [ -e "/proc/`cat $XoeDir/xoe.services/$Service/pid_file/server_$Service.pid`" ] ; then
		ServiceRunning="$T_Running"
		ServiceRunningStatus="ok"
		ServiceStatus="ok"
		ServiceStoppedStatus="unknown"
		;;
	#else
	*)
		ServiceRunning="$T_Stopped"
		case "$ServiceMode" in
		Auto)
			ServiceStatus="fault"
			ServiceRunningStatus="fault"
			ServiceStoppedStatus="ok"
			;;
		*)
			ServiceStatus="unknown"
			ServiceRunningStatus="unknown"
			ServiceStoppedStatus="ok"
			;;
		esac
		;;
	#fi
	esac
	if [ -f $XoeDir/xoe.services/tryton-60-sslp-173/mode/contract_situation.$Service.mode.conf ] ; then
		ServiceSituation=`cat $XoeDir/xoe.services/tryton-60-sslp-173/mode/contract_situation.$Service.mode.conf`
	else
		ServiceSituation="never"
	fi
	case "$ServiceSituation" in
	installed|validated)
		ServiceRenewStatus="ok"
		;;
	alerted)
		ServiceRenewStatus="warning"
		;;
	never|*)
		ServiceRenewStatus="static"
		;;
	esac
		

	#TR T_Login_url Url to log in : Url de connexion
	#ServiceLoginUrl="<![CDATA[<p>$T_Login_url :<br/><a href=\\\"http://$ServiceUrl\\\" target=\\\"_blank\\\">http://$ServiceUrl</a></p>]]>"
	http_links=""
	for url in $ServiceUrl ; do
		http_links="$http_links <br/><a href=\\\"http://$url\\\" target=\\\"_blank\\\">http://$url</a>"
	done
	ServiceLoginUrl="<![CDATA[<p>$T_Login_url :$http_links</p>]]>"
	#TR T_Last_connection Last_connection : Derniere connexion
	#TR T_No_login No login since last service restart : Aucune connexion depuis le dernier redemarrage
	#TR T_Connections Connections since last restart : Connexions depuis le dernier redemarrage
	ServiceLastLogin="<![CDATA[<p>$T_Last_connection :<br/>$ServiceLast</p>]]>"
	if [ -z "$ServiceLastLogin" ] ; then

		ServiceLastLogin="<![CDATA[<p>$T_No_login</p>]]>"
	fi
	#TR T_Resume Summary : Commentaire
	ServiceSummary="<![CDATA[<p>$T_Resume :<br/>$ServiceDocumentation</p>]]>"
	#TR T_started_in_mode started in mode : demarre en mode
	#TR T_is_in_state is in state : est en etat
	ServiceDoc="$T_Service $Service $T_started_in_mode $ServiceMode, $T_is_in_state $ServiceRunning"
	ServiceLogins=`cat $XoeDir/xoe.services/$Service/log/server_$Service.log | grep " login " | sed 's/successful/<font color=#336633>successful/' | sed 's/bad/<font color=#7e0021>bad/' | sed 's/.*/& <\/font><br\/>/'`

	ServiceLogErrors=`tail -n $LogDetailLength $XoeDir/xoe.services/$Service/log/server_$Service.log | grep "ERROR\|WARNG\| WARNING " | sed 's/\"/:/g' | sed 's/\`/:/g' | sed 's/ERROR/<font color=#7e0021>ERROR<\/font>/' | sed 's/WARNG/<font color=#cc6633>WARNG<\/font>/' | sed 's/WARNING/<font color=#cc6633>WARNING<\/font>/' | sed 's/.*/& <br\/>/'`
	ServiceLastActions=`cat $GoeActionsLog | grep "Action:$Service:" | sed 's/.*/& <br\/>/'`
	#TR T_Information_on_service Technical information on service : Information technique sur le service

	#TR T_No_action No action recorded : Aucune action enregistree
	#TR T_Lastactions Recorded actions on service : Historique des actions sur le service
	#TR T_No_anomaly No anomaly since last restart : Pas d'anomalie depuis le dernier redemarrage
	#TR T_Anomalies Anomalies since last restart : Anomalies depuis le dernier redemarrage
	#TR T_Configuration_of_service Configuration of service : Configuration du service
	if [ -f $XoeDir/xoe.services/$Service/documentation/configuration-$Service.conf ] ; then
		XoeServiceInfo="
$T_Configuration_of_service $Service
------------------------------------------
`cat $XoeDir/xoe.services/$Service/documentation/configuration-$Service.conf | sed 's/\"//g'`"
	else
		XoeServiceInfo="
$T_Configuration_of_service $Service
------------------------------------------
Bientot disponible / Next to come"
	fi
	ServiceInformation=`echo "$T_Information_on_service $Service
--------------------------------
$ServiceDoc
Version $ServiceVersion

$XoeServiceInfo" | sed 's/.*/& <br\/>/'`
	if [ -z "$ServiceLogins" ] ; then
		ServiceInformation="$ServiceInformation<br/>------------------------------------------<br/>$T_No_login<br/>------------------------------------------<br/>"
	else
		ServiceInformation="$ServiceInformation<br/>------------------------------------------<br/>$T_Connections :<br/>------------------------------------------<br/>$ServiceLogins<br/>"
	fi
	if [ -z "$ServiceLastActions" ] ; then
		ServiceLastActions="$T_No_action<br/>------------------------------------------<br/>"
	else
		ServiceLastActions="$T_Lastactions :<br/>------------------------------------------<br/>
$ServiceLastActions"
	fi
#	ServiceInformation="${ServiceInformation}<br/>------------------------------------------<br/>
#$ServiceLastActions"

	if [ -z "$ServiceLogErrors" ] ; then
		ServiceLogErrors="$T_No_anomaly<br/>------------------------------------------<br/>"
	else
		ServiceLogErrors="$T_Anomalies :<br/>------------------------------------------<br/>
$ServiceLogErrors"
	fi
	ServiceInformation="${ServiceInformation}<br/>------------------------------------------<br/>
$ServiceLogErrors"


	#TR T_Instructions_of_service Instructions of service : Instructions du service
	if [ -f $XoeDir/xoe.services/$Service/documentation/instructions-$Service.conf.custom ] ; then
		ServiceInstructionsFile="$XoeDir/xoe.services/$Service/documentation/instructions-$Service.conf.custom"
	else
		ServiceInstructionsFile="$XoeDir/xoe.services/$Service/documentation/instructions-$Service.conf"
	fi
	if [ -f $ServiceInstructionsFile ] ; then
		ServiceInstructions="
$T_Instructions_of_service $Service<br/>
------------------------------------------<br/>
`cat $ServiceInstructionsFile | sed 's/\"//g' | sed 's/.*/& <br\/>/'`"
	else
		ServiceInstructions="
$T_Instructions_of_service $Service<br/>
------------------------------------------<br/>
Bientot disponibles / Next to come"
	fi
		

	#TR T_Compatibility Databases must be compatible with service version : Les bases utilisees doivent etre compatibles avec la version du service
	#TR T_Renew_service Renew service subscription : Reconduire l abonnement au service
	#TR T_Renew_alerted is no longer in use and is going to be canceled : n'est plus utilise et va etre supprime
	#TR T_Start_service Start service : Demarrer le service
	#TR T_Stop_service Stop service : Arreter le service
	#TR T_Restart_service Restart service : Redemarrer le service
	#TR T_Use_a_case Use a case reference on service : Utiliser un cas de reference sur le service
	#TR T_Set_a_company Set a company profile to build new cases on service : Definir un profil de societe pour construire des nouveaux cas sur le service
	#TR T_Drop_doc Drop databases whose name begin with a prefix on service : Supprimer des bases de donnees dont le nom commence par un prefixe sur le service
	#TR T_Service_log Last messages from service : Derniers messages du service
	#TR T_EditServiceMenuDoc Add an remove buttons in this menu : Ajouter ou retirer des boutons de ce menu
	ButtonEditServiceMenuDoc="$T_EditServiceMenuDoc"
	ServiceVersionDoc="$T_Compatibility $ServiceVersion"
	case "$ServiceSituation" in
	alerted)
		ButtonRenewDoc="$Service $T_Renew_alerted"
		;;
	*)
		ButtonRenewDoc="$T_Renew_service $Service"
		;;
	esac
	ButtonStartDoc="$T_Start_service $Service"
	ButtonStopDoc="$T_Stop_service $Service"
	ButtonRestartDoc="$T_Restart_service $Service"
	ButtonNewCaseDoc="$T_Use_a_case $Service"
	ButtonCompanyDoc="$T_Set_a_company $Service"
	ButtonDropDoc="$T_Drop_doc $Service"
	#TR T_New_Mooc_doc Declare a new course based on a referenced case of service : Declarer un nouveau cours base sur un cas de reference du service
	ButtonNewMoocDoc="$T_New_Mooc_doc $Service"
	#TR T_Manage_Mooc_doc Open, close and cancel a course of service : Ouvrir, fermer et supprimer un cours du service
	ButtonManageMoocDoc="$T_Manage_Mooc_doc $Service"
	#TR T_Exam_doc Manage a course for an exam session on service : Gerer un cours pour une session d examen sur le service
	ButtonExamDoc="$T_Exam_doc $Service"
	#TR T_Upload_doc Upload a new archive to service : Telecharger une nouvelle archive au service
	ButtonUploadDoc="$T_Upload_doc $Service"
	#TR T_Installarchive_doc Install a new archive to service : Installer une nouvelle archive au service
	ButtonInstallarchiveDoc="$T_Installarchive_doc $Service"
	#TR T_Upgrade_doc Upgrade service to a new version : Montee de version du service
	ButtonUpgradeDoc="$T_Upgrade_doc $Service"
	#TR T_Downgrade_doc Reverse back to previous service version : Retour a la version precedente du service
	ButtonDowngradeDoc="$T_Downgrade_doc $Service"
	
	if echo "$AllDatabaseList" | grep -q "$PgService " ; then
		DropStatus="ok"
	else
		DropStatus="unknown"
	fi
	ReferenceDir=`echo "$ServiceVersion" | cut -b-3`

	CaseStatus="unknown"
	if ls $XoeDir/xoe.packages/database_models/$Service/* >/dev/null 2>&1 ; then
		CaseStatus="ok"
	else
		if ls $XoeDir/xoe.packages/database_models/$ServiceErpName/$ReferenceDir/* >/dev/null 2>&1 ; then
			CaseStatus="ok"
		fi
	fi
	case "$ServiceErpName" in
	tryton)
		CompanyStatus="ok"
		;;
	*)
		CompanyStatus="unknown"
		;;
	esac
	if [ -z "$PgService" ] ; then
		DatabasePgList=""
	else
		DatabasePgList=`echo "$AllDatabaseList" | grep "$PgService" | cut -d"|" -f1 | sed 's/ //g'| sort -u`
	fi
	DatabaseList="$DatabasePgList "
	ArchiveList=`ls $XoeDir/xoe.services/$Service/database | grep -v "^pg-"  | grep -v ".log$" | xargs`
	DatabaseArchiveList=""
	for dbl in $ArchiveList ; do
		if ls $XoeDir/xoe.services/$Service/database/$dbl/*.gz > /dev/null 2>&1 ; then
			DatabaseArchiveList="$DatabaseArchiveList
$dbl"
		fi
	done
	DatabaseList=`echo "$DatabasePgList
$DatabaseArchiveList" | sort -u | xargs`
	DatabaseNumber=`echo "$DatabaseList" | wc -w`
	#LOG_MESSAGE $LINENO -g "Acquisition du service $Service DatabaseList $DatabaseList"
	ServiceLogTailText=`tail -n $LogTailLength $XoeDir/xoe.services/$Service/log/server_$Service.log | grep -v " 400 -"$ | sed 's/\"/:/g' | sed 's/\`/:/g' | sed 's/.*/& <br\/>/'`
	ServiceLogTail="<![CDATA[
$T_Service_log $Service :<br/>
------------------------------------------<br/>
$ServiceLogTailText]]>"
	if [ -f $XoeDir/xoe.services/$Service/log/server_$Service.log ] ; then
		ServiceLogText=`tail -n $LogDetailLength $XoeDir/xoe.services/$Service/log/server_$Service.log | grep -v " 400 -"$ | sed 's/\"/:/g' | sed 's/\`/:/g' | sed 's/ERROR/<big><strong><font color=#7e0021>ERROR<\/font><\/strong><\/big>/g' | sed 's/WARNG/<font color=#cc6633>WARNG<\/font>/g' | sed 's/WARNING/<font color=#cc6633>WARNING<\/font>/g' | sed 's/.*/& <br\/>/'`
	else
		ServiceLogText="Bientot disponible / Next to come <br\/>"
	fi
	ServiceLogDetail="<![CDATA[<hr/><p>$T_Service_log $Service :<br/>------------------------------------------<br/>$ServiceLogText</p><hr/>]]>"
	if echo "$ServiceLogText" | grep -qi "Traceback\|ERROR$" ; then
		ServiceLogTailStatus="fault"
	else
		if echo "$ServiceLogText" | grep -qi "WARNING" ; then
		ServiceLogTailStatus="warning"
		else
			ServiceLogTailStatus="ok"
		fi
	fi
	MoocServiceList=`echo "$MoocList" | grep "^$Service:"`
	if echo "$MoocList" | grep -q "^$Service:" ; then
		MoocStatus="ok"
	else
		MoocStatus="unknown"
	fi
	#tester les versions eventuellement ? Tryton et Odoo ? disallowed ? unknown ?
	case "$ServiceRole" in
	production)
		Uploadability="protected"
		ButtonUploadStatus="unknown"
		;;
	*)
		Uploadability="ok"
		ButtonUploadStatus="ok"
		;;
	esac
	#tester les versions eventuellement ? Tryton et Odoo ? disallowed ? unknown ?
	case "$ServiceRole" in
	production)
		Installarchiveability="protected"
		ButtonInstallarchiveStatus="unknown"
		;;
	*)
		#tester si le directory custom est vide
		Installarchiveability="ok"
		ButtonInstallarchiveStatus="ok"
		;;
	esac
	if ! ls $XoeDir/xoe.services/$Service/custom/*.tar.gz > /dev/null 2>&1 && ! ls $XoeDir/xoe.services/$Service/custom/*.zip > /dev/null 2>&1 ; then
		Installarchiveability="unknown"
		ButtonInstallarchiveStatus="unknown"
	fi
	if [ ! -e $XoeDir/xoe.services/$Service/upgraded.txt ] ; then
		Downgradability="unknown"
	else
		Downgradability="ok"
	fi
	if [ ! -z "$ServiceCompatibilityList" ] ; then
		case "$ServiceRole" in
		production)
			Upgradability="unknown"
			;;
		*)
	#if echo "$XoeConf" | grep "^directory:server:$Service:" | grep -q "	bzr\|	hg\|	copy	\|uptodate.tar.gz" ; then
			Upgradability="ok"
			;;
		esac
	else
		Upgradability="unknown"
	fi
	

	#LOG_MESSAGE $LINENO -g  "Upgradability of $Service is flagged to $Upgradability, $ServiceCompatibilityList, $ServiceRole"
	echo "# $GoeData/$Service.service.data generated by $0 on $Date
ServiceButtons=\"$ServiceButtons\"
ServiceStatus=\"$ServiceStatus\"
ServiceDoc=\"$ServiceDoc\"
ServiceErpName=\"$ServiceErpName\"
ServiceVersion=\"$ServiceVersion\"
ServiceVersionDoc=\"$ServiceVersionDoc\"
ServiceRunningStatus=\"$ServiceRunningStatus\"
ServiceRunning=\"$ServiceRunning\"
ServiceRole=\"$ServiceRole\"
ServiceLanguage=\"$ServiceLanguage\"
ServiceLoginUrl=\"$ServiceLoginUrl\"
ServiceLastLogin=\"$ServiceLastLogin\"
ServiceSummary=\"$ServiceSummary\"
ServiceRenewStatus=\"$ServiceRenewStatus\"
ServiceStoppedStatus=\"$ServiceStoppedStatus\"
ButtonRenewDoc=\"$ButtonRenewDoc\"
ButtonStartDoc=\"$ButtonStartDoc\"
ButtonStopDoc=\"$ButtonStopDoc\"
ButtonRestartDoc=\"$ButtonRestartDoc\"
ButtonNewCaseDoc=\"$ButtonNewCaseDoc\"
ButtonCompanyDoc=\"$ButtonCompanyDoc\"
CaseStatus=\"$CaseStatus\"
CompanyStatus=\"$CompanyStatus\"
ButtonDropDoc=\"$ButtonDropDoc\"
DropStatus=\"$DropStatus\"
DatabasePgList=\"$DatabasePgList\"
DatabaseArchiveList=\"$DatabaseArchiveList\"
DatabaseList=\"$DatabaseList\"
DatabaseNumber=\"$DatabaseNumber\"
ButtonNewMoocDoc=\"$ButtonNewMoocDoc\"
ButtonManageMoocDoc=\"$ButtonManageMoocDoc\"
ButtonExamDoc=\"$ButtonExamDoc\"
MoocStatus=\"$MoocStatus\"
MoocServiceList=\"$MoocServiceList\"
Upgradability=\"$Upgradability\"
ButtonUpgradeDoc=\"$ButtonUpgradeDoc\"
ServiceCompatibilityList=\"$ServiceCompatibilityList\"
Downgradability=\"$Downgradability\"
ButtonDowngradeDoc=\"$ButtonDowngradeDoc\"
Uploadability=\"$Uploadability\"
ButtonUploadDoc=\"$ButtonUploadDoc\"
Installarchiveability=\"$Installarchiveability\"
ButtonInstallarchiveDoc=\"$ButtonInstallarchiveDoc\"
ButtonUploadDoc=\"$ButtonUploadDoc\"
ButtonEditServiceMenuDoc=\"$ButtonEditServiceMenuDoc\"

ButtonRenewStatus=\"\$ServiceRenewStatus\"
ButtonStartStatus=\"\$ServiceStoppedStatus\"
ButtonStopStatus=\"\$ServiceStatus\"
ButtonRestartStatus=\"\$ServiceStatus\"
ButtonNewCaseStatus=\"\$CaseStatus\"
ButtonCompanyStatus=\"\$CompanyStatus\"
ButtonDropStatus=\"\$DropStatus\"
ButtonUpgradeStatus=\"\$Upgradability\"
ButtonDowngradeStatus=\"\$Downgradability\"
ButtonUploadStatus=\"$ButtonUploadStatus\"
ButtonInstallarchiveStatus=\"$ButtonInstallarchiveStatus\"
ButtonNewMoocStatus=\"\$CaseStatus\"
ButtonManageMoocStatus=\"\$MoocStatus\"
ButtonExamStatus=\"\$MoocStatus\"
ButtonEditServiceMenuStatus=\"static\"

if [ -f $GoeActingFlag.$Service.flag ] ; then
	#ButtonStartStatus=\"unknown\"
	#ButtonStopStatus=\"unknown\"
	#ButtonRestartStatus=\"unknown\"
	ButtonNewCaseStatus=\"unknown\"
	#ButtonCompanyStatus=\"unknown\"
	ButtonDropStatus=\"unknown\"
	ButtonUpgradeStatus=\"unknown\"
	ButtonDowngradeStatus=\"unknown\"
	ButtonUploadStatus=\"unknown\"
	ButtonInstallarchiveStatus=\"unknown\"
	ButtonNewMoocStatus=\"unknown\"
	ButtonManageMoocStatus=\"unknown\"
	ButtonExamStatus=\"unknown\"
	#ButtonEditServiceMenuStatus=\"unknown\"
fi
#--------------------------------Config
ServiceInformation=\"$ServiceInformation\"
ServiceLastActions=\"$ServiceLastActions\"
ServiceLogErrors=\"$ServiceLogErrors\"
ServiceInstructions=\"$ServiceInstructions\"
#--------------------------------Log
ServiceLogTailStatus=\"$ServiceLogTailStatus\"
ServiceLogTail=\"$ServiceLogTail\"
ServiceLogDetail=\"$ServiceLogDetail\"

" > $Service.service.data.draft

	UPDATE_DATA_FILE $Service.service.data s
	echo "# $GoeData/$Service.dashboard.data generated by $0 on $Date
ServiceStatus=\"$ServiceStatus\"
ServiceDoc=\"$ServiceDoc\"
DatabaseNumber=\"$DatabaseNumber\"
" > $Service.dashboard.data
	#. $Service.service.data
	#cat -n $Service.service.data
	#echo "# $Service.service.data generated by $0 on `date`"
	;;
database)
	#LOG_MESSAGE $LINENO -g  "Acquisition de la base $Database du service $Service"
	#ServiceConfig=`cat $XoeServicesData 2>/dev/null | grep -m 1 "^$Service " `
	GET_XOE_DATA $Service Available_Buttons
	GET_XOE_DATA $Service Enabled_Buttons
	#Available_Buttons=`echo "$ServiceConfig" | cut -d":" -f6 | cut -d"+" -f1`
	#Enabled_Buttons=`echo "$ServiceConfig" | cut -d":" -f6 | cut -d"+" -f2`
	case "$Enabled_Buttons" in
	*-*)
		#remove space if list is empty
		DatabaseButtons=`echo "$Enabled_Buttons" | cut -d- -f2 | xargs`
		;;
	*)
		DatabaseButtons=`echo "$Available_Buttons" | cut -d- -f2 | xargs`
		;;
	esac
	if [ -z "$DatabaseButtons" ] ; then
		case "$ServiceRole" in
		*production)
			DatabaseButtons=`echo "$RestrictedButtonsList" | cut -d- -f2 | xargs`
			;;
		*)
			DatabaseButtons="$DatabaseButtonsDefaultList"
			;;
		esac
	fi
	#echo "DatabaseButtons: ==-Enabled buttons $Enabled_Buttons database buttons $DatabaseButtons==" >> /tmp/DatabaseButtons.$Service
	if  echo "$DatabasePgList" | grep -q "^$Database$" ; then
		DbStatus="ok"
		#TR T_is_active is active : est active
		DbDoc="$T_Database $Database $T_on_service $Service $T_is_active"
	else
		#TR T_is_not_active is not active : n'est pas active
		DbStatus="unknown"
		DbDoc="$T_Database $Database $T_on_service $Service $T_is_not_active"
	fi
	#TR T_was_saved_on was saved on : a ete archivee le
	if  [ -d $XoeDir/xoe.services/$Service/database/$Database ] ; then
		if [ -f "$XoeDir/xoe.services/$Service/database/$Database/last-archive_$Database.sql.gz" ] ; then
			ArchiveDate=`date -r $XoeDir/xoe.services/$Service/database/$Database/last-archive_$Database.sql.gz`
			ArchiveDoc="$T_Database $Database $T_on_service $Service $T_was_saved_on $ArchiveDate"
			ArchiveStatus="ok"
		else
			if [ -f "$XoeDir/xoe.services/$Service/database/$Database/monthly_reference_$Database.sql.gz" ] ; then
				ArchiveDate=`date -r $XoeDir/xoe.services/$Service/database/$Database/monthly_reference_$Database.sql.gz`
				ArchiveDoc="$T_Database $Database $T_on_service $Service $T_was_saved_on $ArchiveDate"
				ArchiveStatus="ok"
			else
				#TR T_Not_saved No archive : Pas de sauvegarde
				#TR T_has_no_archive doesn't have an archive : n'a pas de sauvegarde disponible
				ArchiveDate="<small>$T_Not_saved</small>"
				ArchiveDoc="$T_Database $Database $T_on_service $Service $T_has_no_archive"
				ArchiveStatus="unknown"
			fi
		fi
	else
		ArchiveStatus="unknown"
		ArchiveDoc="$T_Database $Database $T_on_service $Service $T_has_no_archive"
		#TR T_Never_saved Not saved : N'est pas sauvegardee
		ArchiveDate="<small>$T_Never_saved</small>"
	fi
	DbConf=`echo "$XoeConf" | grep "^database:$Service:" | cut -d: -f3 | sort -u | xargs`
	#LOG_MESSAGE $LINENO -g collect database:$Service: DbConf $DbConf
	DbInformation=""
	if [ -z "$DbConf" ] ; then
		#TR T_No_Auto_databases No automated operations on databases on service : Pas de traitement automatique programme pour les bases du service
		DbInformation="$T_No_Auto_databases $Service
---------------------------------------------------------------------------"
	else
		for DbPrefix in $DbConf ; do
			case "$Database" in
			$DbPrefix*)
				#TR T_Auto_database Operations automated on database : Operations automatiques s appliquant a la base de donnees
				DbInformation="$DbInformation
$T_Auto_database $Database
---------------------------------------------------------------------------
 `echo "$XoeConf" | grep "^database:$Service:$DbPrefix:"`"
				;;
			esac
		done
	fi
	case "$ArchiveStatus" in
	ok)
		#TR T_Archive_list Archive list of database : Liste des sauvegardes de la base de donnees
		DbInformation="$DbInformation
$T_Archive_list $Database
---------------------------------------------------------------------------
`ls -lh $XoeDir/xoe.services/$Service/database/$Database | grep -v key$ | grep -v filestore$`"
		;;
	unknown)
		#TR T_No_archive No_archive for database : Pas de sauvegarde disponible de la base de donnees
		DbInformation="$DbInformation
$T_No_archive $Database
---------------------------------------------------------------------------"
		;;
	esac
	case "$ServiceErpName" in
	tryton)
		ButtonDbUpdateStatus="ok"
		;;
	*)
		ButtonDbUpdateStatus="unknown"
		;;
	esac

	DbInformation=`echo "$DbInformation" | sed 's/.*/& <br\/>/'`
	#TR T_Server_log Last messages in server log : Derniers messages du serveur
	LogTail="<![CDATA[<p>$T_Server_log :<br/>------------------------------------------<br/>$LogTailText</p>]]>"
	#TR T_Save_database Save database : Sauvegarder la base de donnees
	ButtonSaveDoc="$T_Save_database $Database $T_on_service $Service"
	#TR T_Snapshot_database	Set auto save mode of database : Activer la sauvegarde periodique de la base de donnees
	ButtonSnapshotDoc="$T_Snapshot_database $Database $T_on_service $Service"
	#TR T_Restore_database Restore_database : Restaurer la base de donnees
	ButtonRestoreDoc="$T_Restore_database $Database $T_on_service $Service"
	#TR T_Clone_database Clone database : Cloner la base de donnees
	#TR T_to_several_copies to several copies : en plusieurs exemplaires
	ButtonCloneDoc="$T_Clone_database $Database $T_on_service $Service $T_to_several_copies"
	#TR T_Copy_database Copy database : Copier la base de donnees
	#TR T_to_another_service to another service : sur un autre service
	ButtonCopyDoc="$T_Copy_database $Database $T_on_service $Service $T_to_another_service"
	#TR T_Reference_database Create a reference from database : Creer une reference de la base de donnees
	ButtonReferenceDoc="$T_Reference_database $Database $T_on_service $Service"
	#TR T_Delete_database Delete database : Suppression de la base de donnees
	ButtonDeleteDoc="$T_Delete_database $Database $T_on_service $Service"
	#TR T_Delete_archives_of_database Delete archives of database : Effacement des sauvegardes de la base de donnees
	ButtonWipeOutDoc="$T_Delete_archives_of_database $Database $T_on_service $Service"
	#TR T_Update_database Update database : Mise a jour de la base de donnees
	ButtonDbUpdateDoc="$T_Update_database $Database $T_on_service $Service"
	#TR T_EditDatabaseMenuDoc Add an remove buttons in this menu : Ajouter ou retirer des boutons de ce menu
	ButtonEditDatabaseMenuDoc="$T_EditDatabaseMenuDoc"

	#TR T_DatabaseLastactions Last recorded actions on this database : Dernieres actions enregistrees sur cette base de donnees
	DatabaseLastActions=`cat $GoeActionsLog | grep "Action:$Service:$Database:" | tail -n 3 | sed 's/.*/& <br\/>/'`
	if [ -z "$DatabaseLastActions" ] ; then
		DatabaseLastActions="$T_No_action<br/>------------------------------------------<br/>"
	else
		DatabaseLastActions="$T_DatabaseLastactions :<br/>------------------------------------------<br/>
$DatabaseLastActions"
	fi

	echo "# $GoeData/$Service.$Database.database.data generated by $0 on $Date
DatabaseButtons=\"$DatabaseButtons\"
DbStatus=\"$DbStatus\"
DbDoc=\"$DbDoc\"
DbInformation=\"$DbInformation\"
ArchiveDoc=\"$ArchiveDoc\"
ArchiveStatus=\"$ArchiveStatus\"
ArchiveDate=\"$ArchiveDate\"
ButtonDbUpdateStatus=\"$ButtonDbUpdateStatus\"
ButtonSaveDoc=\"$ButtonSaveDoc\"
ButtonSnapshotDoc=\"$ButtonSnapshotDoc\"
ButtonRestoreDoc=\"$ButtonRestoreDoc\"
ButtonCloneDoc=\"$ButtonCloneDoc\"
ButtonCopyDoc=\"$ButtonCopyDoc\"
ButtonReferenceDoc=\"$ButtonReferenceDoc\"
ButtonDeleteDoc=\"$ButtonDeleteDoc\"
ButtonWipeOutDoc=\"$ButtonWipeOutDoc\"
ButtonDbUpdateDoc=\"$ButtonDbUpdateDoc\"
ButtonEditDatabaseMenuDoc=\"$ButtonEditDatabaseMenuDoc\"
DatabaseLastActions=\"$DatabaseLastActions\"

ButtonSaveStatus=\"\$DbStatus\"
ButtonSnapshotStatus=\"\$DbStatus\"
ButtonRestoreStatus=\"\$ArchiveStatus\"
ButtonCloneStatus=\"\$ArchiveStatus\"
ButtonCopyStatus=\"\$ArchiveStatus\"
ButtonReferenceStatus=\"\$ArchiveStatus\"
ButtonDeleteStatus=\"\$DbStatus\"
ButtonWipeOutStatus=\"\$ArchiveStatus\"
ButtonEditDatabaseMenuStatus=\"static\"

if [ -f $GoeActingFlag.$Service.flag ] ; then
	ButtonSaveStatus=\"unknown\"
	ButtonSnapshotStatus=\"unknown\"
	ButtonRestoreStatus=\"unknown\"
	ButtonCloneStatus=\"unknown\"
	ButtonCopyStatus=\"unknown\"
	ButtonReferenceStatus=\"unknown\"
	ButtonDeleteStatus=\"unknown\"
	ButtonWipeOutStatus=\"unknown\"
	ButtonDbUpdateStatus=\"unknown\"
	#ButtonEditDatabaseMenuStatus=\"unknown\"
fi
" > $Service.$Database.database.data.draft
	UPDATE_DATA_FILE $Service.$Database.database.data d
	#. $Service.$Database.database.data
	#cat -n 	$Service.$Database.database.data
	#echo "# $Service.$Database.database.data generated by $0 on `date`"
	;;
general_log)
	case "$ServerLogMode" in
	show)
		LogTailText=`tail -n $GeneralLogTailLength $XoeLog | sed 's/\"/:/g' | sed 's/\`/:/g' | sed 's/.*/& <br\/>/'`
		#TR T_Server_log Server last log : Derniers messages du serveur
		LogTail="<![CDATA[<p>$T_Server_log :<br/>------------------------------------------<br/>$LogTailText</p>]]>"
		LogDetailText=`tail -n $GeneralLogDetailLength $XoeLog | sed 's/\"/:/g' | sed 's/\`/:/g' | sed 's/ERROR/<big><strong><font color=#7e0021>ERROR<\/font><\/strong><\/big>/g' | sed 's/WARNG/<font color=#cc6633>WARNG<\/font>/g'  | sed 's/WARNING/<font color=#cc6633>WARNING<\/font>/g' | sed 's/.*/& <br\/>/'`
		LogDetail="<![CDATA[<hr/><p>$T_Server_log :<br/>------------------------------------------<br/>$LogDetailText</p><hr/>]]>"
		if echo "$LogDetailText" | grep -qi "Traceback\|ERROR$" ; then
			LogTailStatus="fault"
		else
			if echo "$LogDetailText" | grep -qi "WARNING" ; then
			LogTailStatus="warning"
			else
				LogTailStatus="ok"
			fi
		fi
		echo "# $GoeData/general_log.data generated by $0 on $Date
LogTail=\"$LogTail\"
LogDetail=\"$LogDetail\"
LogTailStatus=\"$LogTailStatus\"" > general_log.data.draft
		UPDATE_DATA_FILE general_log.data l
		;;
	esac
	;;
esac
#LOG_MESSAGE $LINENO $data_type collect done on `date +'%Hh%Mm%Ss:%3N'`
}
#end 
#------------------------------------------------------------------------------
#--collect suite et fin
	#LOG_MESSAGE $LINENO -g execution collect $* data for all services
	#echo -n "collect `date +'%Hh%Mm%Ss:%3N'` ...." >> $GoeDir/goe.draw.log
	LOG_MESSAGE $LINENO "New data to be collected on `date +'%Hh%Mm%Ss:%3N'`"
	XoeConf=`cat $XoeDir/xoe.conf/xoe.services.conf | grep -v "^#"`
	AllDatabaseList=`psql -l`
	if [ ! -f $PageLog ] ; then
		echo "page" >> $PageLog
	fi
	PageList=`tail -n $PageHistory $PageLog | sort -u | xargs`
	#PageList=`cat $PageLog | xargs`
	LOG_MESSAGE $LINENO collect PageList $PageList
	COLLECT_DATA page
	case "$PageList" in
	*page*)
		COLLECT_DATA contract
		COLLECT_DATA admin_guide
		COLLECT_DATA openservice
		COLLECT_DATA closeservice
		COLLECT_DATA system
		COLLECT_DATA mooc
		COLLECT_DATA general_log
		;;
	esac
	LOG_MESSAGE $LINENO collect ServiceList $ServiceList
	for Service in $ServiceList ; do
		case "$PageList" in
		*$Service*|*page*)
			LOG_MESSAGE $LINENO -g --collect Service $Service
			COLLECT_DATA service
			for Database in $DatabaseList ; do
				LOG_MESSAGE $LINENO -g --collect service $Service Database $Database
				COLLECT_DATA database
			done
			;;
		esac
	done
	LOG_MESSAGE $LINENO "Last data collected on `date +'%Hh%Mm%Ss:%3N'`"
	#echo ".... `date +'%Hh%Mm%Ss:%3N'`" >> $GoeDir/goe.draw.log
	;;
#------------------------------------------------------------------------------
--get_service_list)
#------------------------------------------------------------------------------
	/usr/local/bin/xoe --config -list -data > $XoeServicesData
	;;
#------------------------------------------------------------------------------
--background)
#------------------------------------------------------------------------------
	runningprocesses=`ps axo cmd`
	if echo "$runningprocesses" | grep 'goe' | grep -q 'loop' ; then
		LOG_MESSAGE $LINENO -g "--backgroung Process loop is running, consider --loop_stop for a graceful stop"
		echo "Process loop is running, consider --loop_stop for a graceful stop"
		exit 0
	else
		rm -f $ActivityFile
		nohup $0 --loop 2>$GoeLog &
		LOG_MESSAGE $LINENO -g "Loop is started --loop, use $0 --loop_stop for a graceful stop"
		echo "Loop is started --loop, use $0 --loop_stop for a graceful stop"
	fi
	;;
#------------------------------------------------------------------------------
--loop)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
LOOP ()
#------------------------------------------------------------------------------
{
#in crontab /usr/loca/bin/goe --bakground x10 6
MOOC_EXECUTE ()
{
LOG_MESSAGE $LINENO -g mooc execute mode $ServerMode
if [ -f /usr/local/bin/mooc ] ; then
	/usr/local/bin/mooc --background
fi
}
#end 
#------------------------------------------------------------------------------
LOOP_PARAMETERS ()
#------------------------------------------------------------------------------
{
#echo "backgd  `date +'%Hh%Mm%Ss:%3N'` $NumberTimes" >> $GoeDir/goe.draw.log
if [ -z "$NumberTimes" ] ; then
	NumberTimes="Auto"
fi
rating="is not evaluated"
case "$ServerMode" in
idemdemo*)
	xTimes="0"
	;;
*)
	case "$NumberTimes" in
	x*)
		xTimes=`echo "$NumberTimes" | cut -b2-`
		;;	
	esac
	if [ ! -z "$Period" ] ; then
		Pace="$Period"
	fi
	case "-$xTimes-$Pace-$NumberTimes-" in
	*-Auto*|*-auto*)
		nbdb=`psql -l 2>/dev/null | grep -m 1 "rows" | cut -d"(" -f2 | cut -d" " -f1`
		nb_databases=`echo "$nbdb - 3" | bc`
		GET_XOE_DATA
		#nbsrv=`cat $XoeServicesData | wc -l`
		#ServiceNumber=`echo "$nbsrv - 1" | bc`
		rating=`echo "$ServiceNumber * 10 + $nb_databases" | bc`
		echo "$rating" > $SiteRefreshModeFile.rating
		if [ $rating -le 30 ] ; then
			xTimes="6"
			Pace="10"
			echo "12" > $SiteRefreshPeriodFile
			echo "All" > $SiteRefreshModeFile
		else
			if [ $rating -le 36 ] ; then
				xTimes="6"
				Pace="10"
				echo "16" > $SiteRefreshPeriodFile
				echo "All" > $SiteRefreshModeFile
			else
				if [ $rating -le 128 ] ; then
					xTimes="4"
					Pace="12"
					echo "16" > $SiteRefreshPeriodFile
					echo "$RefreshMode" > $SiteRefreshModeFile
				else
					if [ $rating -le 256 ] ; then
						xTimes="3"
						Pace="15"
						echo "20" > $SiteRefreshPeriodFile
						echo "Displayed" > $SiteRefreshModeFile
					else
						if [ $rating -le 384 ] ; then
							xTimes="2"
							Pace="20"
							echo "24" > $SiteRefreshPeriodFile
							echo "Displayed" > $SiteRefreshModeFile
						else
							if [ $rating -le 640 ] ; then
								xTimes="2"
								Pace="20"
								echo "24" > $SiteRefreshPeriodFile
								echo "Displayed" > $SiteRefreshModeFile
							else
								if [ $rating -le 1024 ] ; then
									xTimes="2"
									Pace="20"
									echo "24" > $SiteRefreshPeriodFile
									echo "Displayed" > $SiteRefreshModeFile
								else
									xTimes="1"
									Pace="60"
									echo "32" > $SiteRefreshPeriodFile
									echo "Displayed" > $SiteRefreshModeFile
								fi
							fi
						fi
					fi
				fi
			fi
		fi
		;;
	esac
	;;
esac
#TR T_There_is There is : Il y a
#TR T_There_are There are : Il y a
#TR T_database_over database over : base de donnees sur
#TR T_databases_over databases over : bases de donnees sur
#TR T_service service : service
#TR T_services services : services
#TR T_Delay Delay to next evaluation : Prochain calcul apres
#TR T_Disk_size_eval Disk is evaluated once a day : Le disque est evalue 1 fois par jour
case "$nb_databases"-"$ServiceNumber" in
0-0|0-1|1-0|1-1)
	echo "$T_Disk_size_eval. $T_There_is $nb_databases $T_database_over $ServiceNumber $T_service" > $GoeDir/goe.pace_time.conf
	;;
0-*|1-*)
	echo "$T_Disk_size_eval. $T_There_is $nb_databases $T_database_over $ServiceNumber $T_services" > $GoeDir/goe.pace_time.conf
	;;
*-0|*-1)
	echo "$T_Disk_size_eval. $T_There_is $nb_databases $T_databases_over $ServiceNumber $T_service" > $GoeDir/goe.pace_time.conf
	;;
*)
	echo "$T_Disk_size_eval. $T_There_are $nb_databases $T_databases_over $ServiceNumber $T_services" > $GoeDir/goe.pace_time.conf
	;;
esac
LOG_MESSAGE $LINENO -g "LOOP_PARAMETERS rating: $rating, $xTimes x refresh, $Pace s naptime, `cat $SiteRefreshPeriodFile` s display period, refresh mode is `cat $SiteRefreshModeFile`"
}
#end 
#------------------------------------------------------------------------------
#LOOP
	if [ ! -e "$ActivityFile" ] ; then
		echo -n "1234567890" > $ActivityFile
		LastTime="15"
	else
		LastTime=`cat $ActivityFile | wc -c`
	fi
	LOG_MESSAGE $LINENO -g Age of most recent frontend activity : $LastTime data refresh cycles
	MOOC_EXECUTE
	if [ $LastTime -le 20 ] ; then
		#LOG_MESSAGE $LINENO -g looping
		$0 --get_service_list
		LOOP_PARAMETERS
		$0 --collect
		$0 --template
		$0 --draw
		echo -n "i" >> $ActivityFile
		#LOG_MESSAGE $LINENO -g starting loop to collect data and redraw pages `cat $ActivityFile`
		for (( iloop=2; iloop<=$xTimes; iloop++ )) ; do
			sleep $Pace
			LastTime=`cat $ActivityFile | wc -c`
			if [ $LastTime -le 12 ] ; then
				$0 --collect
				$0 --draw
				#LOG_MESSAGE $LINENO -g collect data and redraw $i
				echo -n ":" >> $ActivityFile
			fi
		done
		some_time=`echo "$Pace - 5" | bc`
		sleep $some_time
		LOG_MESSAGE $LINENO -g "end of loop to collect data and redraw pages, age of last frontend activity: `cat $ActivityFile | wc -c` cycles"
	else
		if [ $LastTime -le 25 ] ; then
			$0 --draw_default
		else
			rm -f $GoeDataLog
		fi
		echo -n "." >> $ActivityFile
		sleep 5
	fi

}
#--loop
	LOG_MESSAGE $LINENO -g "Starting execution loop forever, use $0 --loop_stop for a graceful stop"
	echo "$$" > $GoePidFile
	chmod 600 $GoePidFile
	while [ ! -f  $LoopStatus ] ; do
		LOOP
		sleep 5
	done
	rm -f $LoopStatus
	rm -f $GoePidFile
	LOG_MESSAGE $LINENO -g "Execution loop is stopped, use $0 --background to restart this loop"
	;;
#------------------------------------------------------------------------------
--loop_status)
#------------------------------------------------------------------------------
	runningprocesses=`ps axo cmd`
	if echo "$runningprocesses" | grep 'goe' | grep -q '$0 --loop' ; then
		echo "Loop status: loop is looping"
	else
		echo "Loop status: no loop is looping"
	fi
	;;


#------------------------------------------------------------------------------
--loop_stop)
#------------------------------------------------------------------------------
	if [ -f "$GoePidFile" ] ; then

		echo "Process loop is invited to stop"
		echo "please stop looping" >  $LoopStatus
	else
		echo "Process loop is already stopped"
		rm -f  $LoopStatus
	fi
	;;
#------------------------------------------------------------------------------
--new_login)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		case "$ServerMode" in
		*)
			if [ -z "$UserName" ] ; then
				echo -n "New login : "
				read UserName
			fi
			if echo "$UserLogins" | grep -qm 1 "^$UserName " ; then
				LOG_MESSAGE $LINENO -e $UserName is already declared in configuration
			else
				if [ -f "$XoeServicesData" ] && cat $XoeServicesData 2>/dev/null | grep "^#Service:$UserName:" >/dev/null 2>&1 ; then
					LOG_MESSAGE $LINENO -e $UserName is already declared in $XoeServicesData
				else
					if [ -z "$UserPassword" ] ; then
						echo -n "New password : "
						read UserPassword
					fi
					if [ -z "$UserRole" ] ; then
						echo -n "New role : "
						read UserRole
					fi
					echo "UserLogins=\"$UserLogins
$UserName $UserPassword $UserRole\"" > $GoeLoginConf
					echo "Login $UserName is added to $GoeLoginConf"
				fi
			fi
			;;
		esac
		;;
	*)
		echo "You must be root or use sudo to setup a new login"
		;;
	esac
	;;

#------------------------------------------------------------------------------
--config)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		cd /usr/local
		if [ ! -e etc ] ; then
			mkdir etc
		fi
		if [ ! -e etc/goe ] ; then
			mkdir etc/goe
		fi
		if [ ! -f "$GoeConf" ] ; then
			cat $0 2>/dev/null | grep -m 1 -B 200 "^##EndConfig" | grep -A 200 "^##StartConfig" > $GoeConf
			echo "Default configuration is set in $GoeConf"
		else
			echo "This is current configuration of goe in $GoeConf : "
			echo "Last Update : `stat -c %z $GoeConf | cut -d"." -f1`"
			cat $GoeConf
		fi
		chmod 755 $GoeConf
		
		if [ ! -f "$GoeLocalConf" ] ; then
			echo "Local configuration file $GoeLocalConf is not found"
		else
			echo "This is current local configuration of goe in $GoeLocalConf : "
			echo "Last Update : `stat -c %z $GoeLocalConf | cut -d"." -f1`"
			cat $GoeLocalConf
		fi
		chmod 755 $GoeLocalConf
		;;
	*)
		if [ ! -f $GoeConf ] ; then
			echo "You must be root or use sudo to setup default configuration in /$GoeConf"
			echo "Here is the default configuration of goe"
			cat $0 2>/dev/null | grep -m 1 -B 200 "^##EndConfig" | grep -A 200 "^##StartConfig"
		else
			echo "This is current configuration of goe in $GoeConf :"
			echo "Last Update : `stat -c %z $GoeConf | cut -d"." -f1`"
			cat $GoeConf
			echo "This is current local configuration of goe in $GoeLocalConf :"
			cat $GoeLocalConf
		fi
		if [ -f $GoeModeConf ] ; then
			echo "This is current mode configuration of goe in $GoeModeConf"
			cat $GoeModeConf
		fi
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--config_reset)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		cd /usr/local
		if [ ! -e etc ] ; then
			mkdir etc
		fi
		if [ ! -e etc/goe ] ; then
			mkdir etc/goe
		fi
		cat $0 2>/dev/null | grep -m 1 -B 1000 "^##EndConfig" | grep -A 1000 "^##StartConfig" > $GoeConf
		echo "Default configuration is reset in $GoeConf"
		chmod 755 $GoeConf
		echo "#Local configuration of goe"	> $GoeLocalConf
		cat $0 2>/dev/null | grep -m 1 -B 1000 "^##EndConfig" | grep -A 1000 "^##LocalConfig" > $GoeLocalConf
		chmod 755 $GoeLocalConf
		;;
	*)
		echo "You must be root or sudo to reset default configuration in $GoeConf"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--config_update)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		cd /usr/local
		if [ ! -e etc ] ; then
			mkdir etc
		fi
		if [ ! -e etc/goe ] ; then
			mkdir etc/goe
		fi
		if [ -f $GoeConf ] ; then
			CustomParameters=`cat $GoeConf 2>/dev/null | grep -m 1 -A 1000 "^##EndConfig" | grep -v "#"`
		fi
		if [ -f $GoeLocalConf ] ; then
			CustomLocalParameters=`cat $GoeLocalConf 2>/dev/null | grep -m 1 -A 1000 "^##EndConfig" | grep -v "#" | grep .`
		fi
		$0 --config_reset
		echo "$CustomParameters" >> $GoeLocalConf
		echo "$CustomLocalParameters" >> $GoeLocalConf
		;;
	*)
		echo "You must be root or sudo to update configuration in $GoeConf"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--config_edit)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		cd /usr/local
		if [ ! -e etc ] ; then
			mkdir etc
		fi
		if [ ! -e etc/goe ] ; then
			mkdir etc/goe
		fi
		if [ ! -f $GoeLocalConf ] ; then
			echo "#Local configuration of goe"	> $GoeLocalConf
		fi
		nano $GoeLocalConf
		echo "Changes are kept in $GoeLocalConf"
		;;
	*)
		nano $GoeLocalConf
		echo "Changes are kept in local conf"
		;;
	esac
	;;
#------------------------------------------------------------------------------
--dashboard)
#------------------------------------------------------------------------------	
#toggle parameters options|contract|admin_guide|monitor|mooc|services|log show|hide
#list help support options contract monitor mooc services log
echo "$LINENO `date` $DashboardOption $OptionParameters" >> /tmp/goe.dashboard.newservice.log
TOGGLE ()
{
tog_file="$1"
shift
tog_line="$*"
before_content=`cat $tog_file | grep -v "^$tog_line"`
echo "$before_content" > $tog_file
echo "$tog_line" >> $tog_file
}
	case `whoami` in
	root)
		case "$DashboardValue" in
		show|hide)
			;;
		*)
			DashboardValue="show"
			;;
		esac
		if [ -z "$DashboardList" ] ; then
			DashboardList="help support"
		fi
		case "$DashboardOption" in
		list)
			TOGGLE $GoeLocalConf "ServerMenuEnabled=\"$DashboardList\""
			TOGGLE $GoeLocalConf "ServerMenuMode=\"hide\""
			;;
		options)
			TOGGLE $GoeLocalConf "ServerMenuMode=\"$DashboardValue\""
			;;
		admin_guide)
			TOGGLE $GoeLocalConf "AdminGuideMode=\"$DashboardValue\""
			;;
		contract)
			TOGGLE $GoeLocalConf "ServerContractMode=\"$DashboardValue\""
			;;
		openservice)
			TOGGLE $GoeLocalConf "OpenServiceMode=\"$DashboardValue\""
			;;
		closeservice)
			TOGGLE $GoeLocalConf "CloseServiceMode=\"$DashboardValue\""
			;;
		monitor)
			TOGGLE $GoeLocalConf "SystemInfoMode=\"$DashboardValue\""
			;;
		mooc)
			TOGGLE $GoeLocalConf "MoocInfoMode=\"$DashboardValue\""
			;;
		services)
			TOGGLE $GoeLocalConf "ServiceDetailsMode=\"$DashboardValue\""
			;;
		log)
			TOGGLE $GoeLocalConf "ServerLogMode=\"$DashboardValue\""
			;;
		newservice)
			nohup /usr/local/bin/xoe --contract -automated $DashboardList > /dev/null 2>&1 &
			echo "$LINENO `date` sudo /usr/local/bin/xoe --contract -automated $DashboardList" >> /tmp/goe.dashboard.newservice.log
			;;
		esac
		;;
	*)
		echo "You must be root"
		;;
	esac
	;;
#------------------------------------------------------------------------------
--log)
#------------------------------------------------------------------------------
	if [ -z "$SearchString" ] ; then
		cat -n $GoeLogFile
	else
		cat -n $GoeLogFile | grep "$SearchString"
	fi
	;;
#------------------------------------------------------------------------------
--live)
#------------------------------------------------------------------------------
	if [ -z "$SearchString" ] ; then
		tail -f $GoeLogFile
	else
		tail -f $GoeLogFile | grep "$SearchString"
	fi
	;;
#------------------------------------------------------------------------------
--mode)
#------------------------------------------------------------------------------
#echo "New mode $NewMode"
	case "$NewMode" in
	demo|business|education)
		;;
	*)
		echo "Current mode is $ServerMode"
		echo "New mode $NewMode should be in demo|business|education"
		exit $LINENO
		;;
	esac
	case `whoami` in
	root)
		case "$NewMode" in
		$ServerMode)
			;;
		demo|education)
			echo "
ServerMode=\"$NewMode\""  > $GoeModeConf
			/usr/local/bin/mooc --mode on
			;;
		*|business)
			#echo "mode is written to $GoeModeConf"
			echo "
ServerMode=\"$NewMode\""  > $GoeModeConf
			/usr/local/bin/mooc --mode off
			;;
		esac
		echo "this new setting is kept in $GoeModeConf"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--set_authorized_user)
#------------------------------------------------------------------------------
	if [ -z "$SetAuthorizedUser" ] ; then
		echo -n  "ERP authorized user :  "
		read SetAuthorizedUser
	fi
	case `whoami` in
	root)
		case "$SetAuthorizedUser" in
		$XoeAuthorizedUser)
			;;
		*)
			if [ ! -f $GoeLocalConf ] ; then
				echo "#Local configuration of goe"	> $GoeLocalConf
			fi
			echo "XoeAuthorizedUser=\"$SetAuthorizedUser\""  >> $GoeLocalConf
			echo "this new setting is kept in $GoeLocalConf"
			;;
		esac
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--set_log)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		case "$NewMode" in
		on)
			case "$GoeLog" in
			$GoeLogFile)
				;;
			*)
				echo "GoeLog=\"$GoeLogFile\""  >> $GoeLocalConf
				echo "Log mode is set to on" >> $GoeLogFile
				;;
			esac
			;;
		off)
			case "$GoeLog" in
			/dev/null)
				;;
			*)
				echo "GoeLog=\"/dev/null\""  >> $GoeLocalConf
				echo "Log mode is set to off" >> $GoeLogFile
				;;
			esac
			;;
		esac
		echo "this new setting is kept in $GoeLocalConf"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--shell)
#------------------------------------------------------------------------------
	LOG_MESSAGE $LINENO -g execute as `whoami` shell command $ShellCommand
	$ShellCommand
	exit 0
	;;
#------------------------------------------------------------------------------
--shell_move)
#------------------------------------------------------------------------------
	LOG_MESSAGE $LINENO -g move uploaded files as `whoami` from/to $ShellCommand
	origin=`echo "$ShellCommand" | cut -d" " -f1`
	destination=`echo "$ShellCommand" | cut -d" " -f2`
	if [ ! -z "$origin" ] && [ ! -z "$destination" ] ; then
		rm -f $origin/*' '*
		mv $origin/* $destination
	else
		LOG_MESSAGE $LINENO -g move uploaded files as `whoami` from/to are mandatory
	fi
	exit 0
	;;
#------------------------------------------------------------------------------
--install_panel)
#------------------------------------------------------------------------------
	case `whoami` in
	root)

#-------------------------------------------------------------------------
PHP_CAPABILITY ()
#-------------------------------------------------------------------------
{
	if cat /etc/issue | grep -q "10.04\|11.04\|12.04\|14.04\|16.04\|Debian GNU/Linux 7" ; then
		echo "5"
	else
		echo "7"
	fi
}
#end 
#-------------------------------------------------------------------------
INSTALL_PHP_CAPABILITY ()
#-------------------------------------------------------------------------
{
	iphpc_version=`PHP_CAPABILITY`
	apt-get install fontconfig xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils
	case "$iphpc_version" in
	5)
		if ! apt-get install php5 ; then
			echo "Failure during php5 installation."
		fi
		;;
	7)
		if apt-get install php ; then
			
			PHP_UPLOAD_MAX
		else
			echo "Failure during PHP7 installation."
		fi
		;;
	esac
	if ! apt-get install php-xml* ; then
		echo "Failure during PHP-XML installation."
	fi
	LOG_MESSAGE $LINENO -g PHP installed version is $iphpc_version
}
#end 
#-------------------------------------------------------------------------
		if ! apt-get install apache2 ; then
			echo "Failure during Apache2 installation."
		fi
		INSTALL_PHP_CAPABILITY
		goe_location="/`cat /etc/apache2/sites-enabled/*default* | grep DocumentRoot | cut -d/ -f2-`"
		if [ ! -e "$goe_location" ] ; then
			echo "cannot find Apache2 DocumentRoot for $Option option, not done"
			exit $LINENO
		fi
		if [ -f $goe_location/index.html ] ; then
			mv $goe_location/index.html $goe_location/.index.html.dist
		fi
		# create apache virtualhost
		$0 --update_panel
		$0 --config_reset
		su $XoeAuthorizedUser -c '/usr/local/bin/goe --init'
		if ! cat /var/spool/cron/crontabs/$XoeAuthorizedUser | grep -q "/usr/local/bin/goe" ; then
			echo "
* * * * *   /usr/local/bin/goe  --background  > /dev/null 2>&1" >> /var/spool/cron/crontabs/$XoeAuthorizedUser
		fi
		# Corriger les droits d'acces
		chmod 600 /var/spool/cron/crontabs/$XoeAuthorizedUser
		chown $XoeAuthorizedUser /var/spool/cron/crontabs/$XoeAuthorizedUser
		chgrp crontab /var/spool/cron/crontabs/$XoeAuthorizedUser
		if [ -f $goe_location/robots.txt ] ; then
			mv $goe_location/robots.txt $goe_location/.robots.txt.dist
		fi
		RobotFileName="$goe_location/robots.txt"
		echo "User-agent: *
Disallow: /" > $RobotFileName
		# add $HttpUser to sudoers
		# ??
		if ! cat /etc/sudoers | grep -q "$HttpUser ALL = NOPASSWD: /usr/local/bin/goe" ; then
			echo "$HttpUser ALL = NOPASSWD: /usr/local/bin/goe" >> /etc/sudoers
		fi
		if ! cat /etc/sudoers | grep -q "$HttpUser ALL = NOPASSWD: /usr/local/bin/xoe" ; then
			echo "$HttpUser ALL = NOPASSWD: /usr/local/bin/xoe" >> /etc/sudoers
		fi
		/etc/init.d/apache2 restart
		$0 --update_mooc
		;;
	*)
		echo "you must be root or sudo to succeed with $Option option"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--update)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		LOG_MESSAGE $LINENO -g goe $Option Nouvelle version $*
		cd /usr/local/bin
		script_source=`basename $0`
		panel_source=""
		css_source=""
		if [ ! -z "$CodeAltSource" ] ; then
			case "$CodeAltSource" in
			*,*,*)
				download_source=`echo "$CodeAltSource" | cut -d"," -f1`
				panel_source=`echo "$CodeAltSource" | cut -d"," -f2`
				css_source=`echo "$CodeAltSource" | cut -d"," -f3`
				;;
			*,*)
				download_source=`echo "$CodeAltSource" | cut -d"," -f1`
				panel_source=`echo "$CodeAltSource" | cut -d"," -f2`
				;;
			*)
				download_source="$CodeAltSource"
				;;
			esac
		else
			download_source="$GoeDownloadSource"
		fi
		OLDVERSION=`$0 --version -noblabla`
		if wget -q $download_source -O $script_source.new_version ; then
			diff $script_source $script_source.new_version
			mv $script_source rescue.$script_source
			mv $script_source.new_version $script_source
			chmod 755 $script_source
			rm -f $GoeTranslationFile.*
			NEWVERSION=`$0 --version -noblabla`
			case "$NEWVERSION" in
			$OLDVERSION)
				echo "$0 is uptodate `$0 --version`"
				;;
			*)
				echo "$0 downloaded new version from $download_source"
				;;
			esac
			$0 --config_update
			$0 --update_mooc
			$0 --update_panel $panel_source $css_source
			$0 --loop_stop
		else
			echo "$0 could not update $script_source software from $download_source"
		fi
		;;
	*)
		echo "$0 you must be root or sudo to succeed with $Option option"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--update_mooc)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		LOG_MESSAGE $LINENO -g goe $Option Nouvelle version $*
		cd /usr/local/bin
		download_source="$MoocDownloadSource"
		script_source="mooc"
		if [ ! -f $script_source ] ; then
			if wget -q $download_source -O $script_source.new_version ; then
				diff $script_source $script_source.new_version
				mv $script_source.new_version $script_source
				chmod 755 $script_source
				#first activation checks permissions and configuration
				/usr/local/bin/mooc --version
			else
				echo "could not download $script_source software from $download_source"
			fi
		else
			chmod 755 $script_source
			/usr/local/bin/mooc --update
		fi
		;;
	*)
		echo "you must be root or sudo to succeed with $Option option"
		;;
	esac
	exit 0
	;;
#------------------------------------------------------------------------------
--update_panel)
#------------------------------------------------------------------------------
	case `whoami` in
	root)
		LOG_MESSAGE $LINENO -g goe $Option Nouvelle version $CodeAltSource
		goe_location="/`cat /etc/apache2/sites-enabled/*default* | grep DocumentRoot | cut -d/ -f2-`"
		if [ ! -e "$goe_location" ] ; then
			echo "cannot find Apache2 DocumentRoot for $Option option, not done"
			exit $LINENO
		fi
		cd $goe_location
		panel_source="$PanelDownloadSource"
		css_source="$CssDownloadSource"
		if [ ! -z "$CodeAltSource" ] ; then
			case "$CodeAltSource" in
			*,*)
				panel_source=`echo "$CodeAltSource" | cut -d"," -f1`
				css_source=`echo "$CodeAltSource" | cut -d"," -f2`
				;;
			*)
				panel_source="$CodeAltSource"
				;;
			esac
		fi
		if wget -q $panel_source -O $SiteScriptName.new_version ; then
			if [ -f "$SiteScriptName" ] ; then
				diff $SiteScriptName $SiteScriptName.new_version
				mv $SiteScriptName rescue.`basename $SiteScriptName`
			fi
			mv $SiteScriptName.new_version $SiteScriptName
			chown $HttpUser $SiteScriptName
			echo "goe panel is up-to-date"
		else
			echo "Could not update panel software from $PanelDownloadSource"
		fi
		if wget -q $css_source -O $SiteCss.new_version ; then
			if [ -f "$SiteCss" ] ; then
				diff $SiteCss $SiteCss.new_version
				mv $SiteCss rescue.$SiteCss
			fi
			mv $SiteCss.new_version $SiteCss
			chown $HttpUser $SiteCss
			echo "goe panel css is up-to-date"
		else
			echo "Could not update css file from $css_source"
		fi
		rm -rf $SiteImages
		if ! wget -q -r -np -nH -nd -R index.html $ImageSource -P $SiteImages ; then
			echo "Could not update images from $ImageSource"
		fi
		echo "<?php
// php code generated by $0 version $ThisScriptVersion
function bytesToSize1024(\$bytes, \$precision = 2) {
    \$unit = array('B','KB','MB');
    return @round(\$bytes / pow(1024, (\$i = floor(log(\$bytes, 1024)))), \$precision).' '.\$unit[\$i];
}
if (isset(\$_POST['service']))
{
	\$serviceName = \$_POST['service'];
}
\$errorCode = \$_FILES['archive_upload']['error'];
\$fileName = \$_FILES['archive_upload']['name'];
\$fileType = \$_FILES['archive_upload']['type'];
\$fileExtension = pathinfo(\$fileName, PATHINFO_EXTENSION);
\$fileBytes = \$_FILES['archive_upload']['size'];
\$fileSize = bytesToSize1024(\$_FILES['archive_upload']['size'], 1);
\$fileTemp = \$_FILES['archive_upload']['tmp_name'];
\$targetFile = \"$GoeUploads/\$serviceName/\$fileName\";
\$dirService = \"$GoeUploads/\$serviceName\";
\$acceptedExtensions = ['tar.gz','zip'];
//echo \"<p>Your file: \".\$fileName.\" has been successfully received.</p>\";
echo \"<p>Type: \".\$fileType.\"</p>\";
echo \"<p>Size: \".\$fileSize.\"</p>\";
//echo \"<p>file: \".\$fileTemp.\"</p>\";
echo \"<p>copy: \".\$targetFile.\"</p>\";
if(\$errorCode === 1)
{
	echo \"<p>Fichier trop gros, refuse. File is too large, rejected.</p>\";
}
elseif(\$error_Code === 2)
{
	echo \"<p>File error code 2</p>\";
	exit;
}
elseif(\$error_Code === 3)
{
	echo \"<p>File error code 3</p>\";
	exit;
}
elseif(\$error_Code === 4)
{
	echo \"<p>Le fichier est vide -File is empty</p>\";
	exit;
}
elseif(\$fileBytes > $MaxArchiveUploadSize)
{
	echo \"<p>Le fichier est trop gros.The file is too big. Max : $MaxArchiveUploadSize.</p>\";
	exit;
}
elseif(!in_array(\$fileExtension,\$acceptedExtensions))
{
	echo \"<p>Les archives acceptees sont au formats .tar.gz ou .zip, sans espace dans le nom. Accepted archives are .tar.gz or .zip file, no space in name.</p>\";
	exit;
}
if (!is_dir(\$dirService))
	mkdir(\$dirService, 0777);
\$is_uploaded = move_uploaded_file(\$fileTemp, \$targetFile);
if(\$is_uploaded)
{
	echo \"<p>Le fichier \".\$fileName.\" peut etre ajoute a la bibliotheque specifique du service. File \".\$fileName.\" uploaded successfully to specific library of service</p>\";
}
else
{
	echo \"<p>File not uploaded.</p>\";
}
?>
"	> upload.php.new_version
		if [ -f upload.php ] ; then
			diff upload.php upload.php.new_version
			rm upload.php
		fi
		mv upload.php.new_version upload.php
		echo "goe upload.php is up-to-date"
		PHP_UPLOAD_MAX
		if ! cat /etc/sudoers | grep -q "$HttpUser ALL = NOPASSWD: /usr/local/bin/goe" ; then
			echo "$HttpUser ALL = NOPASSWD: /usr/local/bin/goe" >> /etc/sudoers
		fi
		if ! cat /etc/sudoers | grep -q "$HttpUser ALL = NOPASSWD: /usr/local/bin/xoe" ; then
			echo "$HttpUser ALL = NOPASSWD: /usr/local/bin/xoe" >> /etc/sudoers
		fi
		if ! cat /etc/sudoers | grep -q "$HttpUser ALL = NOPASSWD: /usr/local/bin/mooc" ; then
			echo "$HttpUser ALL = NOPASSWD: /usr/local/bin/mooc" >> /etc/sudoers
		fi
		;;
	*)
		echo "you must be root or sudo to succeed with $Option option"
		;;
	esac
	exit 0
	;;

#------------------------------------------------------------------------------
--css)
#------------------------------------------------------------------------------
	cd $GoeDir
	wget -q $CssDownloadSource -O $GoeDir/copy_of_goe.css
	echo "/* generated by $0 on $Date */"
	cat $GoeDir/copy_of_goe.css
	echo "/* generated by $0 on $Date */"
	;;
#------------------------------------------------------------------------------
--css_check)
#------------------------------------------------------------------------------
	CssContent=`$0 --css`
	PositionList=`cat $0 | grep -v "PositionList=" | grep "<zone_position>" | cut -d">" -f2 | cut -d"<" -f1 | sort -u | xargs`
	echo "List of positions : $PositionList"
	for position in $PositionList ; do
		if ! echo "$CssContent" | grep -q "\.$position" ; then
			echo "Missing css class .$position"
		fi
	done
	StatusList="fault ok unknown warning"
	echo "List of status values : $StatusList"
	for status in $StatusList ; do
		if ! echo "$CssContent" | grep -q "\.$status" ; then
			echo "Missing css class .$status"
		fi
	done
	TypeList=`cat $0 | grep -v "TypeList=" | grep "<zone_type>" | cut -d">" -f2 | cut -d"<" -f1 | sort -u | xargs`
	echo "List of zone types : $TypeList"
	for type in $TypeList ; do
		if ! echo "$CssContent" | grep -q "\.$type" ; then
			echo "Missing css class .$type"
		fi
		for status in $StatusList ; do
			if ! echo "$CssContent" | grep "\.$type" | grep -q "\.$status" ; then
				echo "Defaulted css class .$type .$status"
			fi
		done
	done
	;;
#------------------------------------------------------------------------------
--help)
#------------------------------------------------------------------------------
	echo "goe : application de gestion des services openerp
syntaxe :
goe [login [language]] --command [parameters]
-- are optionnal when login and language are indicated

Command :
--help

--background			#create a loop forever
--collect	[zone_name ] | [service_name [database_name]]
--config
--config_denied_message
--config_head_css
--config_head_title
--config_head_refresh
--config_login_form
--config_mode
--config_page_header
--config_page_footer
--config_page_menu
--config_reset
--config_update
--config_welcome_message
--css_check
--css
--dashboard	options|contract|monitor|mooc|services|log [show]|hide
--dashboard	list help support options contract monitor mooc services log
--draw
--draw_now	zone_name drawing_name
--get_service_list
--init		[zone_name ] | [service_name [database_name]]
--install_panel
--licence
--live		[search_string]
--log		[search_string]
--login
--loop				#used by --background
--loop_status
--loop_stop			#set an indicator to stop gracefully a --loop at next iteration
--mode		demo|business|education
--move_uploaded	upload_dir custom_dir
--new_login	user_name user_password service_name|admin
--on_click	zone_name new_drawing_name action_name [action_parameters]
--on_duty
--page		zone_name drawing_name
--refresh	zone_name drawing_name
--set_authorized_user xoe_administration_username
--set_log	on|off


--shell		shell_command_and_parameters
--shell_move	origin_dir destination_dir
--template
--update	[http://alternative_goe_code_source_url [http://alternative_panel_code_source_url]]
--update_panel
--version [-noblabla]

language= fr|en


Configuration is located in /usr/local/etc/goe/goe.conf after 'goe --config' command as root
Edit the default configuration in /usr/local/etc/goe/goe.local.conf for permanent change
This file is copied to $GoeDir/goe.conf in case of 'goe --config_reset' command, so you can adapt values
until $GoeDir is resetted for example with a 'goe --clean' command
Mode is in goe.mode.conf
# $GoeDir/goe.conf superceeds /usr/local/etc/goe/goe.conf which superceeds defalut values

you must be root for initializing configuration with --config and for the following options
--config_reset
--install_panel
--update
--update_mooc
--update_panel


output file format :
<zone name=\"zone_name\" />
	<markup>data</markup>
</zone>
markup is one of
zone name	introduces a nested zone, name is mandatory
these markups relate to the zone they are declared in
zone_doc_over	specifies information showed when mouse is over an active element
zone_form	html form code
zone_html	html content to be added in the page
zone_label	short text of a button
zone_menu	html code of an element added to a gobal menu zone
zone_on_click	action executed in case of click on the zone area
zone_on_validate	action executed when a form is validated

these markups are used to invoke css styles for the content of the zone and are applied in this order :
zone_position	example zcenter, zright, zleft...
zone_type	example service_name, service_running, database...
zone_status	typically ok, fault, warning and unknown

these are used to set up global setting wherever the declaration is :
zone_refresh	superceedes any previous page refreshment instruction
zone_title	superceedes any previous title set for the current window
zone_window	specifies a name of the pop up window
"
$0 --version
	;;
#------------------------------------------------------------------------------
--licence)
#------------------------------------------------------------------------------
	echo "This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Credits
2012-today: goe is an original work from SISalp, http://sisalp.fr"
	;;
#------------------------------------------------------------------------------
*)
#------------------------------------------------------------------------------
	if [ -z "$Option" ] ; then
		$0 --help
	else
		echo "503 Option $Option is not supported by goe command"
	fi
	;;
esac
exit 0


