#!/usr/bin/perl
# Procedure: framework
# Last update: 24/01/2005
#############################################################################
# Isogest 3.1.8 - Provides an Office Suite by  simple web interface         #
# Copyright (C) 2002 Dante Ortolani  [LucaS]                                #
#                                                                           #
# 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 2            #
# 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, write to the Free Software Foundation,   #
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           #
#############################################################################

use strict;
use Isogest;
MkEnv();

HtmlHead();
TaskHead(	title=>"IG FrameWork",
		width=>650,
		icon=>0);

my ($ini,$fin,$pagine) = MkTaskPage(7*$Isogest::page_results,"framework?tema=$in{tema}");

HLayer (align=>'left',
	layers=>[(	Button("Deep Blue Skin","framework?tema=deepblue"),
			Button("Virgilio Skin", "framework?tema=virgilio"),
			Button("WindowXP Skin",	"framework?tema=windowxp"),
			Button("Dark Skin",	"framework?tema=dark"),
			$pagine,
		)]
	);

TaskMsg("This application show you some IsoGest Framework features. With
buttons above you can see different skin applied to the same gui. Switch
into different tabs to view the features. If you want to see the code of this
application click <a href=\"http://isogest.sf.net/framework\">Here</a>.
<br>If you find a graphic problem with your browser, please let me know and
send information about your browser and operating system to
lucas\@isogest.org",4);


my (%tags)=MkTabs ( labels=>[(	"A Sample Form",
				"A TaskList",
				"A Tabs in a Tabs",
				"Some function",
				"A today calendar",
				"An Html Histogram",
				"About")],
		 width=>700,
		 nowrap=>'true',
		 default=>($in{pos}-1),
		 name=>'tab2');

print $tags{open}[0];

TaskMsg("IsoGest can easily generate sofisticated forms. Put your mouse over
the label of each field to show a short description of input type.",2);
 
FormHead(status=>'rw');

Input ( type=>'hidden', name=>'tema');

Input (	type=>'text',
	show=>'Text Field',
	quickhelp=>"Questo e' un comune campo per l'input del testo. in
			esso e' possibile predisporre delle Regex (perl stile)
			per il controllo del contenuto");

Input (	type=>'date',
	show=>'Date Field',
	name=>'data',
	quickhelp=>"Questo campo e' come uno di tipo text ma predisposto
			appositamente per l'inserimento delle date. Apparte
			il calendario Js che facilita il recupero di una
			data, e' possibile inserire le date in numerosissimi
			modi. Provate per esempio a inserire date del tipo:
			1304; 13; 130404; 13042004 e premere su submit la
			data sara' convertita automaticamente");	

Input (	type=>'textarea',
	show=>'TextArea Field',
	quickhelp=>"Questo campo e' un comune textarea. E' utile notare che
			per ogni tipo di field e' possibile assegnare degli
			attributi tipo size, value, pattern, name, show e
			molti altri che ne definiscono il comportamento");	

Input (	type=>'combo', 
	show=>'Combo Field',
	data=>[('red','blue','cyan')],
	quickhelp=>"Una delle mancanze dei form html e' proprio quella dei
			campi combo. Cioe' la possibilita' di inserire un
			valore o di sceglierne uno da una lista predefinita.");	

Input (	type=>'select',
	show=>'Select Field',
	data=>[('red','blue','cyan')],
	quickhelp=>"I campi select sono i piu' dinamici del framework. E'
			possibile popolarli con array e hash e visualizzarne
			i valori con ordini per valore o per chiave");	

Input (	type=>'logins',
	quickhelp=>"Con questo tipo di campo e' facilissimo creare un campo
			select popolato da tutti gli utenti definiti nel
			sistema",
	show=>'Logins Field');	

Input ( type=>'multiselect',
	show=>'Multiselect field',
	data=>[('red','blue','cyan','yellow','black','green')],
	);
Input (	type=>'submit',
	show=>'Submit Field',
	quickhelp=>"Inviando il form si ricarica lo stesso; questo da la
			possibilita' di vedere come il framework mantiene i
			dati e come nel caso della data ne converte il valore");	

FormFoot();
print $tags{close}[0],$tags{open}[1];

TaskMsg("L'interfaccia con i database e' gestita in Isogest da sole due
funzioni: DbQuery e FetchRow. Con la prima e' possibile passare una query al
database, che sara' parsata e a seconda del \$Isogest::db_driver impostato
subira' delle conversioni nel corrispondente dialetto SQL, permettendo a
Isogest l'uso del modulo appropriato da passare al database. FetchRow si
occupa invece di recuperare la risposta del server che a seconda della query puo' essere un
array o uno scalare. Da notare che le date sia nelle query passate che nei
risultati sono convertite automaticamente secondo il valore che assume
\$Isogest::date_format",2);

TaskListMenu(	["Login"],
		["Cognome Nome"],
		["Data di nascita"]);

DbQuery("select login, nominativo, nascita from personale where login<>''");

TaskListItem(	[$row[0]],
		[$row[1]],
		[$row[2]] ) while (@row = FetchRow());

TaskListFoot(3);
print $tags{close}[1],$tags{open}[2];

TaskMsg("Con la funzione MkTabs() e' facile generare i tabs anche in modo
	 annidato. Cliccate sulle labels per visualizzarne il contenuto.",2);
Br(2);

my (%tags2) = MkTabs (	labels=>[("Tab0".."Tab4")],
			width=>600,
			name=>'tab1');
for (0..4)
 {
  print $tags2{open}[$_].
  	TaskMsg("Quello che vedete racchiudere questo testo e' il risultato
		 di TaskMsg una delle funzioni che serve a visualizzare messaggi in	
		 vari modi",$_).
  	$tags2{close}[$_];
 }

print $tags{close}[2],$tags{open}[3];
TaskListMenu(	["Function"],
		["Value"],
		["Result"]);

TaskListItem(	["MkUrl()"],
		["a=l'acqua"],
		[MkUrl("a=l'acqua")]);

TaskListItem(	["MkLink()"],
		["'''link''' http://www.isogest.org"],
		[MkLink("'''link''' http://www.isogest.org")]);

TaskListItem(	["GetDayByDate()"],
		["13.04.1973"],
		[$days[GetDayByDate("13.04.1973")]]);

TaskListItem(	["GetValuesByDate()"],
		["13.04.1973"],
		['@(13,4,1973)']);

TaskListItem(	["GetDateByFormat()"],
		["1,4,73"],
		["01-04-1973"]);

TaskListItem(	["SumDate()"],
		["13,4,1973,-40"],
		[SumDate(GetValuesByDate("13.04.1973"),-40)]);

TaskListItem(	["CkDate()"],
		["130473"],
		[CkDate("130473")]);

TaskListItem(	["MkByte()"],
		["230000"],
		[MkByte(230000)]);

TaskListFoot(2);

print $tags{close}[3],$tags{open}[4];
TaskMsg("Con MkCalendar() e' possibile generare onthefly calendari che
	possono contenere anche gli eventi di uno specifico utente",2);

print "<table>";
for ("01".."12")
 {
  print "<td valign=top>";
  MkCalendar(	user=>'lucas',
		month=>$_,
		daylink=>"javascript:alert('Your date: CALENDARDATE')",
		showevent=>'none');
  print "</td>";
  print "</tr>" if $_ =~ /04|08/;
 }
print "</table>";

print $tags{close}[4],$tags{open}[5];

TaskMsg("Ecco un esempio di un istogramma con 2 serie di valori. E'
possibile rappresentare fino a 9 serie di valori. La scala e le proporzioni
vengono generate in modo automatico. l'istogramma e' completamente
realizzato in HTML",2);

MkGraph(	title=>'Histogram sample',
		width=>300,
		height=>200,
		rows=>"(100,230,50,54,160)(100,80,210,99,150)(80,130,180,190,100)",
		vars=>"a,b,c,d,e");

print $tags{close}[5],$tags{open}[6],Br(3);
print "<h1>Riusciresti ad avere lo stesso risultato in sole 200 righe di codice?</h1>";
print Br(2),$tags{close}[6];
 
TaskFoot();
HtmlFoot();
