Index: trunk/prototype/modules/calendar/index.php
===================================================================
--- trunk/prototype/modules/calendar/index.php	(revision 5381)
+++ trunk/prototype/modules/calendar/index.php	(revision 5399)
@@ -1,385 +1,85 @@
-<?php
-
-	$GLOBALS['phpgw_info']['flags'] = Array(  'currentapp'    =>      'expressoCalendar',
-						  'noheader'      =>      false,
-						  'nonavbar'      =>      false,
-						  'noappheader'   =>      true,
-						  'noappfooter'   =>      true,
-						  'nofooter'      =>      true  );
-
-	include('../../../header.inc.php');
-        
-        $_SESSION['flags']['currentapp']  = 'expressoCalendar';
-        
-        
-	$_SESSION['wallet']['Sieve']['user']          = $GLOBALS['phpgw_info']['user']['account_lid'];
-	$_SESSION['wallet']['Sieve']['password']      = $GLOBALS['phpgw_info']['user']['passwd'];
-
-	$_SESSION['wallet']['Cyrus']['user']          = $GLOBALS['phpgw_info']['user']['account_lid'];
-	$_SESSION['wallet']['Cyrus']['password']      = $GLOBALS['phpgw_info']['user']['passwd'];
-
-	$_SESSION['wallet']['user']['uid']	      =  $GLOBALS['phpgw_info']['user']['userid'];
-        $_SESSION['wallet']['user']['uidNumber']      =  $GLOBALS['phpgw_info']['user']['account_id'];
-        $_SESSION['wallet']['user']['password']       =  $GLOBALS['phpgw_info']['user']['passwd'];
-        $_SESSION['wallet']['user']['cn']             =  $GLOBALS['phpgw_info']['user']['cn'];
-        $_SESSION['wallet']['user']['mail']           =  $GLOBALS['phpgw_info']['user']['email'];
-        		
-        //Configuração caldav
-        $_SESSION['config']['expressoCalendar']['useCaldav'] = false;
-        $_SESSION['wallet']['caldav']['url'] = 'http://davical.prognus.com.br/caldav.php';
-        /////////////////////////////////////////////////////////////////////////////////////////////////////
-        
-	$_SESSION['wallet']['PostgreSQL']['user']     = $GLOBALS['phpgw_info']['server']['db_user'];
-	$_SESSION['wallet']['PostgreSQL']['password'] = $GLOBALS['phpgw_info']['server']['db_pass'];
-	$_SESSION['wallet']['PostgreSQL']['dbname']   = $GLOBALS['phpgw_info']['server']['db_name'];
-	$_SESSION['wallet']['PostgreSQL']['host']     = $GLOBALS['phpgw_info']['server']['db_host'];
-?>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<script>
-	function dump(arr,level) {
-		var dumped_text = "";
-		if(!level) level = 0;
-
-		//The padding given at the beginning of the line.
-		var level_padding = "";
-		for(var j=0;j<level+1;j++) level_padding += "    ";
-
-		if(typeof(arr) == 'object') { //Array/Hashes/Objects
-			for(var item in arr) {
-				var value = arr[item];
-
-				if(typeof(value) == 'object') { //If it is an array,
-					dumped_text += level_padding + "'" + item + "' ...\n";
-					dumped_text += dump(value,level+1);
-				} else {
-					dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
-				}
-			}
-		} else { //Stings/Chars/Numbers etc.
-			dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
-		}
-		return dumped_text;
-	}
-</script>
+<script type='text/javascript' src='js/debug.js'></script>
 <!--<link rel='stylesheet' type='text/css' href="../../../templates/jquery-ui/redmond/jquery-ui.css"/>-->
 
 <!--<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.css' />-->
 <link rel="stylesheet" type="text/css" href="css/reset.css" />
-<link rel='stylesheet' type='text/css' href='../../app/plugins/fullcalendar/fullcalendar.css' />
-<link rel='stylesheet' type='text/css' href='../../app/plugins/fullcalendar/fullcalendar.print.css' media='print' />
-<link rel='stylesheet' type='text/css' href='../../app/plugins/jquery/jquery-ui.custom.css'/>
-<link rel='stylesheet' type='text/css' href='../../app/plugins/icalendar/jquery.icalendar.css'/>
-<link type="text/css" href="../../app/plugins/fgmenu/fg.menu.css" media="screen" rel="stylesheet" />
+<link rel='stylesheet' type='text/css' href='../../plugins/fullcalendar/fullcalendar.css' />
+<link rel='stylesheet' type='text/css' href='../../plugins/fullcalendar/fullcalendar.print.css' media='print' />
+<link rel='stylesheet' type='text/css' href='../../plugins/jquery/jquery-ui.custom.css'/>
+<link rel='stylesheet' type='text/css' href='../../plugins/icalendar/jquery.icalendar.css'/>
+<link rel="stylesheet" type="text/css" href="../../plugins/fgmenu/fg.menu.css" media="screen"/>
 <!--<link type="text/css" href="../../fgmenu/theme/ui.all.css" media="screen" rel="stylesheet" />-->
 
-<link rel='stylesheet' type='text/css' href='../../app/plugins/fileupload/jquery.fileupload-ui.css'/>
-<link rel="stylesheet" href="../../app/plugins/jquery.pagination/pagination.css" />
+<link rel='stylesheet' type='text/css' href='../../plugins/fileupload/jquery.fileupload-ui.css'/>
+<link rel="stylesheet" type='text/css' href="../../plugins/jquery.pagination/pagination.css" />
 
 <!-- JPicker -->
-<link rel="Stylesheet" type="text/css" href="../../app/plugins/jpicker/css/jPicker-1.1.6.min.css" />
-<link rel="Stylesheet" type="text/css" href="../../app/plugins/jpicker/jPicker.css" />
+<link rel="Stylesheet" type="text/css" href="../../plugins/jpicker/css/jPicker-1.1.6.min.css" />
+<link rel="Stylesheet" type="text/css" href="../../plugins/jpicker/jPicker.css" />
 
-<link rel="Stylesheet" type="text/css" href="../../app/plugins/farbtastic/farbtastic.css" />
-<link rel="Stylesheet" type="text/css" href="../../app/plugins/timepicker/jquery-ui-timepicker-addon.css" />
-<link rel="stylesheet" type="text/css" href='../../app/plugins/zebradialog/css/zebra_dialog.css'></link>
+<link rel="Stylesheet" type="text/css" href="../../plugins/farbtastic/farbtastic.css" />
+<link rel="Stylesheet" type="text/css" href="../../plugins/timepicker/jquery-ui-timepicker-addon.css" />
+<link rel="stylesheet" type="text/css" href='../../plugins/zebradialog/css/zebra_dialog.css'></link>
 
 <link rel="stylesheet" type="text/css" href="css/layout.css" />
 <link rel="stylesheet" type="text/css" href="css/style.css" />
 
-<script type='text/javascript' src='../../app/plugins/datejs/date-pt-BR.js'></script>
-<script type='text/javascript' src='../../app/plugins/jquery/jquery.min.js'></script>
-<script type='text/javascript' src='../../app/plugins/icalendar/jquery.icalendar.js'></script>
-<script type='text/javascript' src='../../app/plugins/jquery/jquery-ui.custom.min.js'></script>
-<script type='text/javascript' src="../../app/plugins/jquery/i18n/jquery.ui.datepicker-pt-BR.js"></script>
-<script type='text/javascript' src="../../app/plugins/timepicker/jquery-ui-timepicker-addon.js"></script>
-<script type='text/javascript' src="../../app/plugins/timepicker/localization/jquery-ui-timepicker-pt-BR.js"></script>
-<script type='text/javascript' src='../../app/plugins/json2/json2.js'></script>
-<script type='text/javascript' src='../../app/plugins/store/jquery.store.js'></script>
-<script type='text/javascript' src='../../app/plugins/fileupload/jquery.fileupload.js'></script>
-<script type='text/javascript' src='../../app/plugins/fileupload/jquery.fileupload-ui.js'></script>
-<script type='text/javascript' src='../../app/plugins/fileupload/jquery.iframe-transport.js'></script>
-<script type='text/javascript' src='../../app/plugins/store/jquery.store.js'></script>
-<script type="text/javascript" src="../../app/plugins/jquery.pagination/jquery.pagination.js"></script>
-<script type='text/javascript' src='../../app/plugins/mask/jquery.maskedinput.js'></script>
-<script type='text/javascript' src='../../app/plugins/alphanumeric/jquery.alphanumeric.js'></script>
-<script type='text/javascript' src='../../app/plugins/watermark/jquery.watermarkinput.js'></script>
-<script type='text/javascript' src='../../app/plugins/encoder/encoder.js'></script>
-<script type='text/javascript' src='../../app/datalayer.js'></script>
+<script type='text/javascript' src='../../plugins/datejs/date-pt-BR.js'></script>
+<script type='text/javascript' src='../../plugins/jquery/jquery.min.js'></script>
+<script type='text/javascript' src='../../plugins/icalendar/jquery.icalendar.js'></script>
+<script type='text/javascript' src='../../plugins/jquery/jquery-ui.custom.min.js'></script>
+<script type='text/javascript' src="../../plugins/jquery/i18n/jquery.ui.datepicker-pt-BR.js"></script>
+<script type='text/javascript' src="../../plugins/timepicker/jquery-ui-timepicker-addon.js"></script>
+<script type='text/javascript' src="../../plugins/timepicker/localization/jquery-ui-timepicker-pt-BR.js"></script>
+<script type='text/javascript' src='../../plugins/json2/json2.js'></script>
+<script type='text/javascript' src='../../plugins/store/jquery.store.js'></script>
+<script type='text/javascript' src='../../plugins/fileupload/jquery.fileupload.js'></script>
+<script type='text/javascript' src='../../plugins/fileupload/jquery.fileupload-ui.js'></script>
+<script type='text/javascript' src='../../plugins/fileupload/jquery.iframe-transport.js'></script>
+<script type='text/javascript' src='../../plugins/store/jquery.store.js'></script>
+<script type="text/javascript" src="../../plugins/jquery.pagination/jquery.pagination.js"></script>
+<script type='text/javascript' src='../../plugins/mask/jquery.maskedinput.js'></script>
+<script type='text/javascript' src='../../plugins/alphanumeric/jquery.alphanumeric.js'></script>
+<script type='text/javascript' src='../../plugins/watermark/jquery.watermarkinput.js'></script>
+<script type='text/javascript' src='../../plugins/encoder/encoder.js'></script>
+<script type='text/javascript' src='../../api/datalayer.js'></script>
 
 <!-- Datejs -->    
 <!-- <script type='text/javascript' src='../../datejs/core.js'></script> -->
-<!--<script type='text/javascript' src='../../app/plugins/datejs/date-pt-BR.js'></script>-->
-<!-- <script type='text/javascript' src='../../app/plugins/datejs/globalization/pt-BR.js'></script> -->
-<script type='text/javascript' src='../../app/plugins/datejs/sugarpak.js'></script>
-<script type='text/javascript' src='../../app/plugins/datejs/parser.js'></script>
+<!-- <script type='text/javascript' src='../../plugins/datejs/date-pt-BR.js'></script>-->
+<!-- <script type='text/javascript' src='../../plugins/datejs/globalization/pt-BR.js'></script> -->
+<script type='text/javascript' src='../../plugins/datejs/sugarpak.js'></script>
+<script type='text/javascript' src='../../plugins/datejs/parser.js'></script>
 
 <!--  <script type='text/javascript' src='../../datejs/time.js'></script>  -->
-<script type='text/javascript' src='../../app/plugins/dateFormat/dateFormat.js'></script>
+<script type='text/javascript' src='../../plugins/dateFormat/dateFormat.js'></script>
+
+<!--<script type='text/javascript' src='../fullcalendar/fullcalendar.min.js'></script>-->
+<script type='text/javascript' src='../../plugins/fullcalendar/fullcalendar.js'></script>
+
+<script type='text/javascript' src='../../plugins/jquery.dateFormat/jquery.dateFormat.js'></script>
+
+<script type='text/javascript' src='../../plugins/zebradialog/javascript/zebra_dialog.js'></script>
+<script type='text/javascript' src='../../plugins/scrollto/jquery.scrollTo.js'></script>
+<!-- <script type='text/javascript' src='../../plugins/view/jquerymx-1.0.custom.min.js'></script> -->
+<script type='text/javascript' src='../../plugins/ejs/ejs.js'></script>
+
+<script type="text/javascript" src="../../plugins/fgmenu/fg.menu.js"></script>
+
+<script type="text/javascript" src="../../plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>
+
+<!-- JPicker -->
+<script type="text/javascript" src="../../plugins/jpicker/jpicker-1.1.6.min.js"></script>
+<script type="text/javascript" src="../../plugins/farbtastic/farbtastic.js"></script>
+
 <script type='text/javascript' src='js/base64.js'></script>
 <script type='text/javascript' src='js/helpers.js'></script>
 <script type='text/javascript' src='js/calendar.codecs.js'></script>
+<script type='text/javascript' src='js/I18n.js'></script>
+<script type="text/javascript" src="js/init.js"></script>
 
-
-
-<!--<script type='text/javascript' src='../fullcalendar/fullcalendar.min.js'></script>-->
-<script type='text/javascript' src='../../app/plugins/fullcalendar/fullcalendar.js'></script>
-<script type='text/javascript' src='js/I18n.js'></script>
-<script type='text/javascript' src='../../app/plugins/jquery.dateFormat/jquery.dateFormat.js'></script>
-
-<script type='text/javascript' src='../../app/plugins/zebradialog/javascript/zebra_dialog.js'></script>
-<script type='text/javascript' src='../../app/plugins/scrollto/jquery.scrollTo.js'></script>
-<!-- <script type='text/javascript' src='../../app/plugins/view/jquerymx-1.0.custom.min.js'></script> -->
-<script type='text/javascript' src='../../app/plugins/ejs/ejs.js'></script>
-
-<script type="text/javascript" src="../../app/plugins/fgmenu/fg.menu.js"></script>
-
-<script type="text/javascript" src="../../app/plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>
-
-<!-- JPicker -->
-<script src="../../app/plugins/jpicker/jpicker-1.1.6.min.js" type="text/javascript"></script>
-
-<script src="../../app/plugins/farbtastic/farbtastic.js" type="text/javascript"></script>
-
-<script type='text/javascript'>
-
-
-$(document).ready(function() {
-
-	refresh_calendars();
-	$tabs = $('#tabs').tabs({
-	    add: function( event, ui ) {
-			User.lastView = $tabs.tabs('option' ,'selected');
-			$tabs.tabs('select', '#' + ui.panel.id);
-		},
-		remove: function( event, ui ) {
-			$tabs.tabs('select', User.lastView);
-		},
-		show: function( event, ui ){
-			delete Calendar.currentViewKey;
-			$('#calendar').fullCalendar('refetchEvents');
-		}
-	})
-	.tabs('option', 'tabTemplate', "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>" );
-
-	/**
-	  * Make a button to close the tab
-	  */
-	$tabs.find( "span.ui-icon-close" ).live( "click", function() {
-		var index = $( "li", $tabs ).index( $( this ).parent() );
-		if($tabs.tabs('option' ,'selected') == index){
-			if($tabs.tabs("length") == 2 && User.lastView != 1)
-				$tabs.tabs( "select", 0);
-			$tabs.tabs( "select", User.lastView);
-		}
-		if($tabs.tabs('option' ,'selected') == 0 || $tabs.tabs('option' ,'selected') == 1)
-			User.lastView = $tabs.tabs('option' ,'selected');
-		if(index != -1)
-		  $tabs.tabs( "remove", index );	
-			
-		
-		});	
-	$('.button.config-menu').button({
-	    icons: {
-		primary: "ui-icon-gear",
-		secondary: "ui-icon-triangle-1-s"
-	    },
-	    text: false
-	});
-      $('.button.add').button({
-	      icons: {
-		      secondary: "ui-icon-plus"
-	      }
-      })
-
-		var miniCalendar = $('.block-vertical-toolbox .mini-calendar').datepicker({
-			dateFormat: 'yy-m-d',
-			//dateFormat: 'DD, d MM, yy',
-			//inline: true,
-			firstDay: dayOfWeek(User.preferences.weekStart),
-			onSelect: function(dateText, inst)
-			{	
-				$tabs.tabs("select", "#calendar");
-				var date = dateText.split('-');
-				var dateFullCalendar = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-');
-				$('#calendar').fullCalendar('gotoDate',date[0],date[1]-1,date[2]);
-				$('#calendar').fullCalendar( 'changeView', 'agendaDay' );
-			}			
-		})
-		.find('.ui-icon-circle-triangle-e').removeClass('ui-icon-circle-triangle-e').addClass('ui-icon-triangle-1-e').end()
-		.find('.ui-icon-circle-triangle-w').removeClass('ui-icon-circle-triangle-w').addClass('ui-icon-triangle-1-w');
-		
-		//Onclick do mês
-		$('.ui-datepicker-title .ui-datepicker-month').live('click',function(){
-			$tabs.tabs("select", "#calendar");
-			$('#calendar').fullCalendar('gotoDate',$(this).siblings('span').html(), Date.getMonthNumberFromName($(this).html() == 'Março' ? 'Mar' : $(this).html()),'01');
- 			$('#calendar').fullCalendar( 'changeView', 'month');
-		});
-		//Onclick do ano
-		$('.ui-datepicker-title .ui-datepicker-year').live('click',function(){
-			$tabs.tabs("select", "#calendar");
-			$('#calendar').fullCalendar('gotoDate',$(this).html(), '0', '01');
-			$('.fc-button-year').click();
-		});
-		
-	//Onclick em um dia do calendário anual
-	$( ".fc-day-number" ).live( "click", function() {
-			
-		var date = $(this).parents('[class*="fc-day-"]').attr('class').match(/fc-day-(\d{4})-(\d{2})-(\d{2})/);
-
-		if (date) date.shift();
-		else return false;
-
-		$('#calendar').fullCalendar('gotoDate',date[0],date[1]-1,date[2]);
-		$('#calendar').fullCalendar( 'changeView', 'agendaDay' );
-	});	
-
-	$('.main-search input.search').keydown(function(event){
-		if(event.keyCode == 13) {
-			Encoder.EncodeType = "entity";
-			//$(this).val($(this).val());
-					
-			add_events_list($(this).val());
-			$(this).val('');
-		}
-	});
-				
-	$('.block-horizontal-toolbox .main-config-menu').menu({
-		content: $('.main-config-menu-content').html(),
-		positionOpts: {
-			posX: 'left', 
-			posY: 'bottom',
-			offsetX: -140,
-			offsetY: 0,
-			directionH: 'right',
-			directionV: 'down', 
-			detectH: true, // do horizontal collision detection  
-			detectV: true, // do vertical collision detection
-			linkToFront: false
-		},
-		flyOut: true,
-		showSpeed: 100,
-		crumbDefaultText: '>'
-	});
-	      
-		$('#trash').droppable({
-			drop: function(event, ui){
-				// 		calendar.fullCalendar( 'removeEvents', ui.draggable.attr('event-id') );
-				DataLayer.remove( "event", ui.draggable.attr('event-id') );
-				$(this).switchClass('empty','full');
-			},
-			tolerance: "touch"
-		});
-
-      /* initialize the calendar
-      -----------------------------------------------------------------*/
-		$(".button.add.add-event").click(function(event){
-			var startEvent = new Date(); 
-			if(startEvent.toString('mm') < 30)
-				startEvent.add({minutes: 30 - parseInt(startEvent.toString('mm'))});
-			else
-				startEvent.add({hours: 1, minutes: '-'+startEvent.toString('mm')});
-			var endEvent = function(date){
-				if(!!User.preferences.defaultCalendar){
-					return Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration != "" ? 
-						(parseInt(date.getTime()) + Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration * 60000) 
-						: (User.preferences.defaultDuration * 60000);
-				}else
-					return parseInt(date.getTime()) + (User.preferences.defaultDuration * 60000);
-			};	
-			eventDetails({ 
-				startTime: startEvent.getTime(),
-				endTime: endEvent(startEvent)
-			}, true );
-		});
-
-	var calendar = $('#calendar').fullCalendar({
-
-		defaultView: User.preferences.defaultCalView,
-		timeFormat: User.preferences.hourFormat,
-		axisFormat: User.preferences.hourFormat,
-		eventSources: Calendar.sources,
-
-		header: {
-			left: 'prev,next today,basicWeek,basicDay',
-			center: 'title',
-			right: 'agendaDay,agendaWeek,month,year'
-		},
-		firstDay: dayOfWeek(User.preferences.weekStart),
-		editable: true,
-		selectable: true,
-		selectHelper: true,
-		droppable: true, // this allows things to be dropped onto the calendar !!!
-		timeFormat: {
-			agenda: 'HH:mm{ - HH:mm}',
-			'': 'HH:mm{ - HH:mm} }'
-		},
-		titleFormat: {
-			month: 'MMMM yyyy',                             
-			week: "dd[ yyyy] { 'a'[ MMM] dd 'de' MMMM '-' yyyy}", 
-			day: 'dddd,  dd MMM, yyyy'
-		},
-		columnFormat:{
-			month: 'ddd',    
-			week: 'ddd dd/MM', 
-			day: 'dddd dd/MM'  
-		},
-		monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ], 
-		monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
-		dayNames: [ 'Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
-		dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
-		dayNamesShortest: ['D','S','T','Q','Q','S','S'],
-		allDayText: 'Dia todo',
-		buttonText: {
-			today: 'hoje',
-			month: 'mês',
-			week: 'semana',
-			day: 'dia',
-			year: 'ano'
-		},
-		
-		eventRender: function( event, element, view ){
-			$(element).attr( 'event-id', event.id );
-		},
-
-		select: function( start, end, allDay, event, view ){
-			eventDetails( { 'start': start,
-					'end': end,
-					'allDay': allDay } );
-		},
-
-		eventDrop: function( event ){
-			DataLayer.put( "schedulable:calendar", event );
-		},
-
-		eventResize: function( event ){
-			DataLayer.put( "schedulable:calendar", event );
-		},
-
-		eventClick: function( evt, event, view ){
-			eventDetails( DataLayer.get( "schedulable", evt.id), true);
-		}
-	});
-	  
-	if($(window).height() < $('body').height()){
-		var hei = $('body').height() - $(window).height();
-		hei = $('#divAppbox').height() - hei;
-		$('#divAppbox').css('max-height', hei);
-		$('#divAppbox').css('min-height', hei);
-		$('body').css('overflow-y','hidden');
-		delete hei;
-	 }
-	  
-	 $(window).resize(function(){
-		$('#divAppbox').css('max-height', $(window).height() - 104);
-		$('#divAppbox').css('min-height', $(window).height() - 104);
-		$('#divAppbox').css('overflow-x', 'auto');
-		$('#divAppbox').css('overflow-y', 'scroll');
-	});	  
-	//Todo chamada do metodo que adiciona ao full calendar o botao de listagem de eventos  
-	//listEvents();
-});
-</script>
 </head>
 
