Index: trunk/calendar_new/setup/setup.inc.php
===================================================================
--- trunk/calendar_new/setup/setup.inc.php	(revision 420)
+++ trunk/calendar_new/setup/setup.inc.php	(revision 573)
@@ -14,14 +14,32 @@
 	/* Conf Table */
 	
-	$setup_info['calendar_new']['author'] = 'Celepar Companhia de Informatica do Parana';
-	$setup_info['calendar_new']['maintainer']	=  'CELEPAR';
-	$setup_info['calendar_new']['maintainer_email']= '';
+	$setup_info['calendar_new']['author'] = 'CELEPAR, Celepar Companhia de Informatica do Parana';
+	$setup_info['calendar_new']['maintainer']	=  'Alexandre Felipe Muller de Souza';
+	$setup_info['calendar_new']['maintainer_email']= 'amuller@celepar.pr.gov.br';
 
-	$setup_info['calendar_new']['license']  	= 'GPL';
+	$setup_info['calendar_new']['license']  	= 'GPL v2';
 	$setup_info['calendar_new']['description'] = 'Calendar Ajax';
+	$setup_info['calendar']['tables'][] = 'phpgw_cal';
+	$setup_info['calendar']['tables'][] = 'phpgw_cal_holidays';
+	$setup_info['calendar']['tables'][] = 'phpgw_cal_repeats';
+	$setup_info['calendar']['tables'][] = 'phpgw_cal_user';
+	$setup_info['calendar']['tables'][] = 'phpgw_cal_extra';
+
 
 	/* The hooks this app includes, needed for hooks registration */
 	$setup_info['calendar_new']['hooks'][] = 'admin';
-		
+	$setup_info['calendar_new']['hooks'][] = 'add_def_prefs';
+	$setup_info['calendar_new']['hooks'][] = 'deleteaccount';
+	$setup_info['calendar_new']['hooks'][] = 'email';
+	$setup_info['calendar_new']['hooks'][] = 'home';
+	$setup_info['calendar_new']['hooks'][] = 'home_day';
+	$setup_info['calendar_new']['hooks'][] = 'home_month';
+	$setup_info['calendar_new']['hooks'][] = 'home_week';
+	$setup_info['calendar_new']['hooks'][] = 'home_year';
+	$setup_info['calendar_new']['hooks'][] = 'manual';
+	$setup_info['calendar_new']['hooks'][] = 'preferences';
+	$setup_info['calendar_new']['hooks'][] = 'settings';
+	$setup_info['calendar_new']['hooks'][] = 'sidebox_menu';
+	
 	/* Dependencies for this app to work */
 	$setup_info['calendar_new']['depends'][] = array(
Index: trunk/calendar_new/xsl/detailsDialog.xsl
===================================================================
--- trunk/calendar_new/xsl/detailsDialog.xsl	(revision 492)
+++ trunk/calendar_new/xsl/detailsDialog.xsl	(revision 573)
@@ -2,5 +2,5 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/retorno">
-<table style="position: absolute; width: 350px; height: 350px;" border="0" cellpadding="0" cellspacing="0">
+<table style="position: absolute; width: 350px; height: 350px;" border="0" cellpadding="0" cellspacing="0"  onmousedown="_dragArea.pressed = 1" onmouseup="_dragArea.pressed = 0" onmousemove="_dragArea.moveWindow(event,this.parentNode)">
 <tbody>
 <tr style="height: 24px;">
@@ -21,4 +21,10 @@
 			<xsl:variable name="description" select="description" />
 			<xsl:variable name="location" select="location" />
+			<xsl:variable name="datetime" select="datetime" />
+			<xsl:variable name="datehour" select="datehour" />
+			<xsl:variable name="dateminute" select="dateminute" />
+			<xsl:variable name="edatetime" select="edatetime" />
+			<xsl:variable name="edatehour" select="edatehour" />
+			<xsl:variable name="edateminute" select="edateminute" />
 			Titulo:<br/>
 			<input type="text" id="dragEventSubject" value="{title}" size="30"></input><br/>
@@ -26,5 +32,11 @@
 			<input type="text" id="dragEventDescription" value="{description}" size="50"></input><br/>
 			Local:<br/>
-			<input type="text" id="dragEventLocation" value="{location}" size="30"></input><br/>
+			<input type="text" id="dragEventLocation" value="{location}" size="30"></input><br/><br/>
+			Data inicio:<input id="startstr" name="startstr" size="10" type="text" value="{datetime}"></input>
+			<img id="trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="Selecionar data" style="cursor: pointer;"></img><br/><br/>
+			Hora de inicio:<input id="starthour" size="2" maxlength="2" value="{datehour}"></input>:<input id="startmin" size="2" maxlength="2" value="{dateminute}"></input><br/><br/>
+			Data de termino:<input id="endstr" name="endstr" type="text" value="{edatetime}"></input>
+			<img id="endstrtrigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="Selecionar data" style="cursor: pointer;"></img><br/><br/>
+			Hora do termino:<input id="endhour" size="2" maxlength="2" value="{edatehour}"></input>:<input id="endmin" size="2" maxlength="2" value="{edateminute}"></input><br/><br/>
 			<div id="saveLink" class="buttontype" style="width:60px;" onclick="saveEvent(null,document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,document.getElementById('dragEventLocation').value,_dragArea.initEvent,_dragArea.endEvent);">Save event</div>
 
Index: trunk/calendar_new/xsl/addDialog.xsl
===================================================================
--- trunk/calendar_new/xsl/addDialog.xsl	(revision 492)
+++ trunk/calendar_new/xsl/addDialog.xsl	(revision 573)
@@ -2,6 +2,5 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/text">
-<div id="infowindow">
-<table style="position: absolute; width: 350px; height: 175px;" border="0" cellpadding="0" cellspacing="0" onmousedown="_dragArea.pressed = 1" onmouseup="_dragArea.pressed = 0"  onmousemove="_dragArea.moveWindow(event)">
+<table style="position: absolute; width: 350px; height: 175px;" border="0" cellpadding="0" cellspacing="0" onmousedown="_dragArea.pressed = 1" onmouseup="_dragArea.pressed = 0" onmousemove="_dragArea.moveWindow(event,this.parentNode)">
 <tbody>
 <tr style="height: 24px;">
@@ -41,5 +40,5 @@
 				<td>
 					<div id="addEventLink" class="buttontype" onclick="quickAddEvent(document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,_dragArea.initEvent,_dragArea.endEvent);">Add event</div></td><td>
-				<div id="addDetailsLink" class="buttontype" onclick="addDetails(null,document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,_dragArea.initEvent,_dragArea.endEvent);">Add with details</div></td>
+				<div id="addDetailsLink" class="buttontype" onclick="addDetails(document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,_dragArea.initEvent,_dragArea.endEvent);">Add with details</div></td>
 			</tr>
 	</tbody></table>
@@ -59,5 +58,4 @@
 </tbody>
 </table>
-</div>
 </xsl:template>
 </xsl:stylesheet>
Index: trunk/calendar_new/inc/hook_admin.inc.php
===================================================================
--- trunk/calendar_new/inc/hook_admin.inc.php	(revision 420)
+++ trunk/calendar_new/inc/hook_admin.inc.php	(revision 573)
@@ -20,2 +20,3 @@
 	display_section($appname,$title,$file);
 ?>
+
Index: trunk/calendar_new/inc/load_lang.php
===================================================================
--- trunk/calendar_new/inc/load_lang.php	(revision 420)
+++ trunk/calendar_new/inc/load_lang.php	(revision 573)
@@ -14,12 +14,8 @@
 		}
 	}
-	$script  = "array_lang[0] = new Array();";
-	$script .= "array_lang[1] = new Array();";		
-	$i = 0;
-	foreach($_SESSION['phpgw_info']['calendar']['lang'] as $key => $value) {		
-		$script .= "array_lang[0][".$i."] = '".str_replace("'","\'",strtolower($key))."';";		
-		$script .= "array_lang[1][".$i."] = '".str_replace("'","\'",$value)."';";
-		$i++;					
-	}
+	$script  = "array_lang = new Array();";
+	foreach($_SESSION['phpgw_info']['calendar']['lang'] as $key => $value)
+		$script .= "array_lang['".str_replace("'","\'",strtolower($key))."'] = '".str_replace("'","\'",$value)."';\n";
 	echo $script;
+
 ?>
Index: trunk/calendar_new/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar_new/inc/class.uicalendar.inc.php	(revision 492)
+++ trunk/calendar_new/inc/class.uicalendar.inc.php	(revision 573)
@@ -14,5 +14,4 @@
 		$this -> db_obj = new bocalendar();
 	}
-
 	var $public_functions = array(
 			'quickAdd' => True,
@@ -201,4 +200,24 @@
 		return $retorno;
 	}
+	function getViewYear () {
+		$monthViewTime = isset ($_REQUEST["time"]) ?  strtotime(substr($_REQUEST["time"],0,4)."-".substr($_REQUEST["time"],6,2)."-".substr($_REQUEST["time"],4,2)) : strtotime(date('Y-m-d', time()));
+
+		$todayTime = strtotime(date('Y-m', $monthViewTime)."-01");
+		$retorno = "<today>".date('Ydm', $monthViewTime)."</today>";
+
+		$fromBo = $this->db_obj->requestYearCal($todayTime);
+		// Printing results in XML
+		if (is_array($fromBo))
+		foreach ($fromBo as $line) {
+			if ($line['datetime'] > 0){
+				$retorno .= "<calEvent>";
+				$retorno .= "<id>".$line['cal_id']."</id>";
+				$retorno .= "<datetime>".($line['datetime']*1000)."</datetime>";
+				$retorno .= "</calEvent>";
+			}
+		}
+		return $retorno;
+	}
+
 
 };
Index: trunk/calendar_new/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar_new/inc/class.bocalendar.inc.php	(revision 492)
+++ trunk/calendar_new/inc/class.bocalendar.inc.php	(revision 573)
@@ -85,4 +85,17 @@
 	}
 
+	// Return the events of current Year
+	function requestYearCal ($dayTime) {
+		// Performing SQL query
+		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+31104000).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+2592000)."))";
+		if (!$this->db->query($query))
+			return false;
+
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		return $result;
+	}
+
 	function insertEvent ($datetime, $edatetime, $title, $description, $location)
 	{
@@ -96,6 +109,5 @@
 
 		// Performing SQL insert query
-		$query = "INSERT INTO phpgw_cal VALUES (".($id['max']+1).", '".$_SESSION['calendar']['user']['email']."', ".$this->user_id.", null, null, ".$datetime.", ".time().",".$edatetime.", 2, 'E', 0, '".$title."', '".$description."', '".$location."', 0, null, null, null )";
-
+		$query = "INSERT INTO phpgw_cal VALUES (".($id['max']+1).", '".$_SESSION['calendar']['user']['email']."', ".$this->user_id.", null, null, ".$datetime.", ".time().",".$edatetime.", 2, 'E', 0, '".$title."', '".$description."', '".$location."', 0, null)";
 		if ($this->db->query($query)){
 			$query = "INSERT INTO phpgw_cal_user VALUES (".($id['max']+1).", ".$this->user_id.", 'A', 'u')";
@@ -136,5 +148,4 @@
 
 		return $return;
-
 	}
 }
Index: trunk/calendar_new/js/drag_area.js
===================================================================
--- trunk/calendar_new/js/drag_area.js	(revision 464)
+++ trunk/calendar_new/js/drag_area.js	(revision 573)
@@ -34,4 +34,5 @@
 	}
 	var id = is_ie ? window.event.srcElement.id : e.target.id;
+	var continues = true;
 	var colorCell = function (id,style){
 		try {
@@ -39,5 +40,5 @@
 		}
 		catch(e)
-		{ document.style.background = "#000"; };
+		{ continues = false; };
 	};
 
@@ -53,15 +54,15 @@
 		if (this.endEvent < this.initEvent)
 			if (id <= this.endEvent)
-				for (var hour = parseInt(this.initEvent); hour >= parseInt(id);hour=incHour(hour,'-')) 
+				for (var hour = parseInt(this.initEvent); hour >= parseInt(id) && continues;hour=incHour(hour,'-')) 
 					colorCell(hour,"#EEE");
 			else
-				for (var hour = parseInt(id); hour >= parseInt(this.endEvent);hour=incHour(hour,'-')) 
+				for (var hour = parseInt(id); hour >= parseInt(this.endEvent) && continues;hour=incHour(hour,'-')) 
 					colorCell(hour,"");
 		else
 			if (id < this.endEvent)
-				for (var hour = parseInt(id); hour <= parseInt(this.endEvent);hour=incHour(hour,'+'))
+				for (var hour = parseInt(id); hour <= parseInt(this.endEvent) && continues;hour=incHour(hour,'+'))
 					colorCell(hour,"");
 			else
-				for (var hour = parseInt(this.initEvent); hour <= parseInt(id);hour=incHour(hour,'+'))
+				for (var hour = parseInt(this.initEvent); hour <= parseInt(id) && continues;hour=incHour(hour,'+'))
 					colorCell(hour,"#EEE");
 		this.endEvent=id;
@@ -96,11 +97,9 @@
 
 counter = 0;
-DragArea.prototype.moveWindow = function(e) {
-	var _event  = is_ie ? window.event : e;
-	var _button = is_ie ? _event.button : _event.which;
-	var id = "divAddDialog";
+DragArea.prototype.moveWindow = function(e,elem) {
 	if (this.pressed){
-		document.getElementById(id).style.left = (_event.clientX - 70) + "px";
-		document.getElementById(id).style.top = (_event.clientY - 70) + "px";
+	        var _event  = is_ie ? window.event : e;
+		elem.style.left = (_event.clientX - 80) + "px";
+		elem.style.top = (_event.clientY - 80) + "px";
 	}
 }
Index: trunk/calendar_new/js/common_functions.js
===================================================================
--- trunk/calendar_new/js/common_functions.js	(revision 492)
+++ trunk/calendar_new/js/common_functions.js	(revision 573)
@@ -50,5 +50,5 @@
 		if (!screenTable[tempDate.getDay()])
 			screenTable[tempDate.getDay()] = new Array();
-		currentPos = 1;	
+		currentPos = 1;
 		if (!screenTable[tempDate.getDay()][start_])
 			screenTable[tempDate.getDay()][start_] = 0;
@@ -67,5 +67,5 @@
 		eventDiv.style.height = "20px";
 		eventDiv.style.cursor = "pointer";
-		eventDiv.onmouseover = function () { this.style.height = "auto"; this.style.zIndex = 2; };
+		eventDiv.onmouseover = function () { this.style.height = "auto"; this.style.zIndex = 2;};
 		eventDiv.onmouseout = function () { this.style.height = "20px"; this.style.zIndex = 1; };
 		eventDiv.onclick = function () { calendar.getView('div_main','Day','&time='+timeStamp2id(eventDiv.childNodes[1].id).substr(0,8)); };
@@ -78,5 +78,5 @@
 		eventDiv.style.width = "60px";
 		eventDiv.style.height = "15px";
-		eventDiv.onmouseover = function () { this.style.width = "auto"; this.style.zIndex = 2; };
+		eventDiv.onmouseover = function () { if (this.childNodes[2].length > 9) this.style.width = "auto"; this.style.zIndex = 2; };
 		eventDiv.onmouseout = function () { this.style.width = "60px"; this.style.zIndex = 1; };
 		eventDiv.onclick = function () { calendar.getView('div_main','Day','&time='+timeStamp2id(eventDiv.childNodes[1].id).substr(0,8)); };
@@ -84,5 +84,5 @@
 
 		tdElement.style.height = (tdElement.childNodes.length * 10) + "px";
-	
+
 		if (tdElement.childNodes.length > 3)
 			eventDiv.style.margin = "20 0 0 "+(20+(tdElement.childNodes.length-4)*25);
@@ -114,5 +114,5 @@
 		showDetailLink.innerHTML = '<img onmouseover="this.setAttribute(\'width\', \'15\');"'+
 			'onmouseout="this.setAttribute(\'width\', \'10\');"'+
-			' title="'+get_lang('details')+'" alt="'+get_lang('details')+'"'+ 
+			' title="'+get_lang('details')+'" alt="'+get_lang('details')+'"'+
 			' src="templates/default/images/plus.png"></img>';
 		showDetailLink.style.position = "absolute";
@@ -130,7 +130,18 @@
 
 function addDetails(title,description,datetime,edatetime){
-	data="<retorno><title>"+title+"</title><description>"+
-	description+"</description><datetime>"+datetime+
-	"</datetime><edatetime>"+edatetime+"</edatetime></retorno>";
+	if (!edatetime)
+		edatetime = "";
+	if (!datetime || datetime.length == 0)
+		datetime = edatetime;
+	data="<retorno>"+
+	"<title>"+title+"</title>"+
+	"<description>"+description+"</description>"+
+	"<datetime>"+datetime.substr(4,2)+"/"+datetime.substr(6,2)+"/"+datetime.substr(0,4)+"</datetime>"+
+	"<datehour>"+datetime.substr(8,2)+"</datehour>"+
+	"<dateminute>"+datetime.substr(10,2)+"</dateminute>"+
+	"<edatetime>"+edatetime.substr(4,2)+"/"+edatetime.substr(6,2)+"/"+edatetime.substr(0,4)+"</edatetime>"+
+	"<edatehour>"+edatetime.substr(8,2)+"</edatehour>"+
+	"<edateminute>"+edatetime.substr(10,2)+"</edateminute>"+
+	"</retorno>";
 
 	var divAddDialog = document.getElementById("divAddDialog");
@@ -151,5 +162,5 @@
 
 function showDetails(eventId){
-	var handler_getDetails = function (data) 
+	var handler_getDetails = function (data)
 	{
 		var divAddDialog = document.getElementById("divAddDialog");
@@ -169,5 +180,24 @@
 		var saveBut = document.getElementById("saveLink");
 		saveBut.onclick = function () { saveEvent(eventId); }
-	}
+		var startDate = document.getElementById('startstr');
+		var endDate = document.getElementById('endstr');
+		var startHour = document.getElementById('starthour');
+		var startMin = document.getElementById('startmin');
+		var endHour = document.getElementById('endhour');
+		var endMin = document.getElementById('endmin');
+		objDate = new Date();
+		objDate.setTime(startDate.value*1000);
+		startDate.value = objDate.getDate()+"/"+(objDate.getMonth()+1)+"/"+objDate.getFullYear();
+		startHour.value = objDate.getHours();
+		startMin.value = objDate.getMinutes();
+		if (startMin.value.length < 2)
+			startMin.value += "0";
+		objDate.setTime(endDate.value*1000);
+		endDate.value = objDate.getDate()+"/"+(objDate.getMonth()+1)+"/"+objDate.getFullYear();
+		endHour.value = objDate.getHours();
+		endMin.value = objDate.getMinutes();
+		if (endMin.value.length < 2)
+			endMin.value += "0";
+		}
 	XMLTools.__RETURN_MODE__ = 'XML';
 	XMLTools.request('$this.uicalendar.getDetails&id='+eventId.id.substr(6), 'GET', handler_getDetails);
@@ -207,7 +237,7 @@
 function saveEvent (id, title, description, locat, startTime, endTime){
 	if (id != null){
-		return changeEvent(id,'location',locat);
-	}
-		
+		return changeEvent(id,'all_fields',locat);
+	}
+
 	var endDate = new Date();
 	endDate.setTime(id2timeStamp(endTime)+1800000);
@@ -296,6 +326,7 @@
 					createEventDiv(objEvent);
 					break;
+				case 'all_fields':
 				default:
-					alert('not implemented');
+					alert(field+': not implemented');
 			}
 	}
@@ -325,21 +356,13 @@
 }
 
-
-function get_lang(_key,_arg1,_arg2,_arg3,_arg4){
-	if (_key.length == 0)
-		return '';
-	if(!array_lang[0]){
-		return _key+"*";
-	}
-	_value = "";
-	for(i = 0; i < array_lang[0].length;i++){
-		if(array_lang[0][i] == _key.toLowerCase()) {
-			_value = array_lang[1][i];
-			break;
-		}
-	}
-
-	if(!_value)
-		return _key+"*";
+// Translate words and phrases using user language from eGroupware.
+function get_lang(_key,_arg1,_arg2,_arg3,_arg4) {
+	if (!_key)
+		return "";
+	var key = _key.toLowerCase();
+		if(array_lang[key])
+			var _value = array_lang[key];
+		else
+			return _key+"*";
 
 	if(_arg1 || _arg2 ||_arg3 || _arg4) {
@@ -351,6 +374,8 @@
 		}
 	}
+
 	return _value;
 }
+
 
 function resizeEvent (eventDiv) {
Index: trunk/calendar_new/js/calendar_functions.js
===================================================================
--- trunk/calendar_new/js/calendar_functions.js	(revision 464)
+++ trunk/calendar_new/js/calendar_functions.js	(revision 573)
@@ -19,9 +19,8 @@
 	}
 
-
 	if(divAddDialog && divAddDialog.style.display != "none"){
 		divAddDialog.style.display = "none";
 		for (var hour = parseInt(_dragArea.initEvent); hour <= parseInt(_dragArea.endEvent);(hour%100 == 30)?hour+=70:hour+=30)
-			document.getElementById(hour).style.background = "";
+			try  { document.getElementById(hour).style.background = ""; } catch (e) { break; };
 		_dragArea.initEvent = null;
 		_dragArea.endEvent = null;
@@ -54,9 +53,4 @@
 	divAddDialog.style.display = "block";
 	divAddDialog.innerHTML = xtools.parse(data, xsl);
-	document.getElementById('dragEventSubject').focus();
-	document.getElementById('addEventLink').innerHTML = get_lang("Add this event");
-	document.getElementById('addDetailsLink').innerHTML = get_lang("Add with details");
-
-
 	var closeButton = document.getElementById('closeDialog');
 	if (is_ie){
@@ -67,4 +61,8 @@
 		closeButton.style.top = '25px';
 	}
+	document.getElementById('dragEventSubject').focus();
+	document.getElementById('addEventLink').innerHTML = get_lang("Add this event");
+	document.getElementById('addDetailsLink').innerHTML = get_lang("Add with details");
+
 
 	this.lastId = _dragArea.endEvent;
