Index: trunk/calendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.bocalendar.inc.php	(revision 641)
+++ trunk/calendar/inc/class.bocalendar.inc.php	(revision 766)
@@ -2169,4 +2169,9 @@
 					$eyear = $syear;
 				}
+				//Tratamento do valor final (mes) da pesquisa de eventos feita em $this->so->list_events.
+				//Se $emonth nao tem valor, recebe o valor de $smonth (que recebe $params['smonth']) e soma 1.
+				//O valor $params['emonth'] indica o mes final para a pesquisa de eventos, e passou a ser
+				//informado na a impressao de eventos mensais. Mudancas feitas em class.uicalendar.inc.php, 
+				//function display_month_print();
 				if(!$emonth)
 				{
@@ -2190,5 +2195,8 @@
 				echo '<!-- End   Date : '.sprintf("%04d%02d%02d",$eyear,$emonth,$eday).' -->'."\n";
 			}
-
+			
+			//A variavel $month_print recebe o parametro 'saux' com o mes de inicio da pesquisa de eventos por
+			//$this->so->list_events. O valor do mes final da pesquisa e tratado no codigo acima;
+			//$month_ini = $params['saux'];
 			if($owner_id)
 			{
Index: trunk/calendar/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.uicalendar.inc.php	(revision 703)
+++ trunk/calendar/inc/class.uicalendar.inc.php	(revision 766)
@@ -374,6 +374,10 @@
 						</tr>
 						<tr>
-							<td><right><input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta p&aacute;gina"></right></td>
-						</tr>						
+						  <td>
+							<div>
+								<input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta p&aacute;gina">
+							</div>
+						   </td>
+						 </tr>
 					</table></body>'."\n"
 					.'</html>'."\n";
@@ -451,10 +455,49 @@
 			}
 
+			if($_POST['year']) {			
+	
+			}
+			
+			$hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow);
+			$mes_hoje = (int)substr($hoje,4,2);
+			$sday = 1;
+			if($_POST['day']) {
+				$day_ini = (int)$_POST['day'];
+			} 
+			elseif($_GET['sday']){
+				if($_GET['month'] == $mes_hoje)
+				{
+					$day_ini = $this->bo->day;
+				} 
+				
+				else
+				{
+					$day_ini = (int)$_GET['sday'];
+				}
+			} 
+			elseif( ($_POST['dia_ini']) && ($_POST['dia_ini'] == $this->bo->day) )
+			{
+				$day_ini = (int)substr($hoje,6,2);
+			}
+			else
+			{
+				$day_ini = $this->bo->day;
+			}
+			if($_POST['qtd_dias'])
+			{
+				$num_dias = (int)$_POST['qtd_dias'];
+			} 
+			else
+			{
+				$num_dias = 0;
+			}
+
 			if (!$this->bo->printer_friendly)
 			{
 				$printer = '';
-				$prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev).'">&lt;&lt;</a>';
-				$next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next).'">&gt;&gt;</a>';
-				$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1';
+				$prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'">&lt;&lt;</a>';
+				$next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">&gt;&gt;</a>';
+				$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias;
+				//$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1';
 				$print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param).
 						"','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '".
@@ -2622,13 +2665,80 @@
 			$p->set_block('footer','footer_row','footer_row');
 			$p->set_block('footer','blank_row','blank_row');
+			$p->set_block('footer','num_dias','num_dias');
 
 			$m = $this->bo->month;
 			$y = $this->bo->year;
 
+			$hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow);
+			$mes_hoje = (int)substr($hoje,4,2);
+			$mes_footer = (int)substr($_POST['date'],4,2);
+			if($_GET['sday'])
+			{
+				if($_GET['month'] == $mes_hoje)
+				{
+					$day = $this->bo->day;
+				} 
+				else
+				{
+					$day = $_GET['sday'];
+				}
+			}
+			else
+			{
+				$day = $this->bo->day;
+				$dia_ini = $day;
+			}
+			if($mes_footer == $mes_hoje)
+			{
+				$dia_ini = (int)substr($hoje,6,2);
+				$day = $dia_ini;
+			}
+			/********************************************************************************************/
+			/* Bloco adicionado para receber o dia a partir do qual a versao para impressao sera gerada */
+			$str_ini = '';
+ 			for ($i = 1; $i <= ($GLOBALS['phpgw']->datetime->days_in_month($m, $y)); $i++)
+			{
+				$str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n";
+			}
+			$str_qtd = '<option value="'.''.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n";
+			for ($i = 1; $i <= 45; $i++)
+			{
+				$str_qtd .= '<option value="'.$i.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.$i.'</option>'."\n";
+			}
+			$display = '';
+			$display_view = '';
+			if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') )
+			{
+				$display = 'none';
+			}
+			else if( ($menuaction == 'calendar.uicalendar.view') )
+			{
+				$display = 'none';
+				$display_view = 'none';
+			}
+			$var = Array(
+				'acao'			=> $this->page($method,''),
+				'formname'		=> 'SelectDay',
+				'formonchange'		=> 'document.SelectDay.submit()',
+				'day_ini_label'		=> lang('print starting in'),
+				'num_dias_label'	=> lang('quantity of days'),
+				'tip'			=> lang('empty prints from the day chosen below to the end of the current month'),
+				'day_ini_name'		=> 'day',
+				'num_dias_name'		=> 'qtd_dias',
+				'row_ini'		=> $str_ini,
+				'row_qtd'		=> $str_qtd,
+				'display'		=> $display,
+				'display_view'		=> $display_view,
+				'go'			=> lang('Go!')
+				);
+			$this->output_template_array($p,'table_row','num_dias',$var);
+			
+			/********************************************************************************************/
+
 			$thisdate = date('Ymd',mktime(0,0,0,$m,1,$y));
 			$y--;
 
 			$str = '';
-			for ($i = 0; $i < 25; $i++)
+			for ($i = 0; $i < 20; $i++)
 			{
 				$m++;
@@ -2650,4 +2760,5 @@
 				'form_onchange'	=> 'document.SelectMonth.submit()',
 				'row'		=> $str,
+				'dia_ini'	=> $dia_ini,
 				'go'		=> lang('Go!')
 			);
@@ -2995,5 +3106,5 @@
 /*****************************************************************************************/
 /*Funcao foi duplicada e alterada para tratar os eventos de agendamento (exibicao do mes) para impressao;
-utiliza o template event_lik.tpl*/
+utiliza o template event_link.tpl*/
 
 		function link_to_month_entry($event,$month,$day,$year)
@@ -3516,42 +3627,5 @@
 		{
 			$this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1);
-
-		//	$p = CreateObject('phpgwapi.Template',$this->template_dir);
 			$p->set_unknowns('remove');
-		//	$p->set_file(
-		//		Array (
-		//			'month_header' => 'month_header_print.tpl'
-		//		)
-		//	);
-	//		$p->set_block('month_header','monthly_header','monthly_header');
-	//		$p->set_block('month_header','column_title','column_title');
-
-/*			$var = Array(
-				'bgcolor'	=> $this->theme['th_bg'],
-				'font_color'	=> $this->theme['th_text']
-			);
-			/*if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white'])
-			{
-				$var = Array(
-					'bgcolor'	=> '',
-					'font_color'	=> ''
-				);
-			}*/
-	/*		$p->set_var($var);
-
-			$p->set_var('col_width','14');
-		/*	if($display_name == True)
-			{
-				$p->set_var('col_title',lang('name'));
-				$p->parse('column_header','column_title',True);
-				$p->set_var('col_width','12');
-			}
-*/
-			//for($i=0;$i<7;$i++)
-			//{
-			//	$p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i]));
-			//	$p->parse('column_header','column_title',True);
-			//}
-//			return $p->fp('out','monthly_header');
 		}
 
@@ -3614,12 +3688,8 @@
 			$p->set_var('extra','');
 			$p->set_var('col_width','14');
-		/*	if($display_name)
-			{
-				$p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner));
-				$p->parse('column_header','month_column',True);
-				$p->set_var('col_width','12');
-			}*/
+			
 			$today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
 			$daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
+
 			foreach($daily as $date => $day_params)
 			{
@@ -3634,18 +3704,10 @@
 				if ($weekly || ($date >= $monthstart && $date <= $monthend))
 				{
-					//if ($day_params['new_event'])
-					//{
-					//	$new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">'
-					//		. '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">'
-					//		. '</a>';
-					//	$day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>';
-					//}
-					//else
-					//{
-						$new_event_link = '';
-						$day_num = $day;
-						$dia_semana = $this->month_day_of_week($year,$month,$day_num);
-						$day_number = $dia_semana . ",  " . $day_num;
-					//}
+					$new_event_link = '';
+					$day_num = $day;
+					$dia_semana = $this->month_day_of_week($year,$month,$day_num);
+					$id_aux = mktime(0,0,0,$month,$day,$year);
+					$month_identifier = substr(lang(strftime("%B",$id_aux)),0,3);
+					$day_number = $month_identifier . " - " . $dia_semana . ",  " . $day_num;
 
 					$var = Array(
@@ -3654,29 +3716,6 @@
 						'day_number'	=> $day_number
 					);
-	/*				if($day_params['week'])
-					{
-
-//NDEE: style! m_w_table in month_day.tpl
-// week-hilite
-						//$var['new_event_link'] .= '<font size="-2"> &nbsp; '.
-	//					$var['new_event_link'] .= ' &nbsp; '.
-	//						(!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'"><span id="calendar_weekinfo" class="calendar_weekinfo">' .$day_params['week'].'</span></a>' : '<span id="calendar_weekinfo" class="calendar_weekinfo">'.$day_params['week'].'</span>');
-					}
-	*/
-			
 
 					$p->set_var($var);
-
-	/*				if(@$day_params['holidays'])
-					{
-						foreach($day_params['holidays'] as $key => $value)
-						{
-							$var = Array(
-								'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br
-							);
-							$this->output_template_array($p,'daily_events','event',$var);
-						
-					}
-	*/
 
 					if($day_params['appts'])
@@ -3688,6 +3727,4 @@
 						$p->set_var($var);
 						$events = $this->bo->cached_events[$date];
-						//eventos
-						//print_r($events);
 						foreach($events as $event)
 						{
@@ -3721,5 +3758,5 @@
 			}
 
-			$this->bo->store_to_cache(
+/*			$this->bo->store_to_cache(
 				Array(
 					'syear'	=> $year,
@@ -3728,9 +3765,49 @@
 				)
 			);
+*/
+			$day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual;
+			$num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial;
 
 			$monthstart = (int)(date('Ymd',mktime(0,0,0,$month    ,1,$year)));
-			$monthend   = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year)));
-
-			$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1);
+//			$monthend   = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year)));
+
+			if($num_dias != 0)
+			{
+				//se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias;
+				$monthend   = (int)(date('Ymd',mktime(0,0,0,$month,$day_ini+$num_dias,$year)));
+			}
+			else
+			{
+				//se a qtde de dias nao for informada, a data final para impressao vai ate o fim do mes corrente;
+				$monthend   = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year)));
+			}
+			
+			if($day_ini != 0)
+			{
+				//o dia de inicio para impressao passa a ser o informado em $day_ini do mes corrente;
+				$start = mktime(0,0,0,$month,$day_ini,$year);
+			}
+			else
+			{
+				//se nao for informado o dia para inicio da impressao, esta comeca no dia 1 do mes corrente;
+				$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1);
+			}
+			//$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 15);
+			$start_d = (int)(date('Ymd',$start));//variavel auxiliar que recebe a data inicial de impressao no formato 'Ymd';
+			$saux = (int)(substr($start_d,4,2));//variavel auxiliar que recebe o mes do inicio da impressao;
+			$eaux = (int)(substr($monthend,4,2)) + 1;//variavel auxiliar que recebe o mes do fim da impressao;
+			//A funcao store_to_cache devolve todos os eventos existentes de determinado usuario em um periodo de tempo
+			//especifico. Originalmente, na impressao mensal, esse periodo de tempo era o mes corrente exibido na tela.
+			//A mudanca consiste no fato de que uma nova variavel ($saux) e enviada com o mes de inicio do periodo
+			//atraves do indice 'smonth' e uma segunda variavel ($eaux) envia o mes final do periodo de tempo atraves
+			//do indice 'emonth'. Vide mais comentarios sobre esses valores em class.bocalendar.inc.php, 
+			//function store_to_cache($params);
+			$this->bo->store_to_cache(
+			Array(
+				'syear'	=> $year,//ano atual
+				'smonth'=> $saux,//mes inicial
+				'emonth'=> $eaux,//mes final
+				'sday'	=> 1
+			));
 
 			$p = CreateObject('phpgwapi.Template',$this->template_dir);
@@ -4560,10 +4637,10 @@
 														<button type='button' onClick='javascript:openListUsers(340,533, "
 														.$event['owner'].
-														")'><img src='calendar/templates/celepar/images/add.png' style='vertical-align: middle;' >&nbsp;Adicionar</button>
+														")'><img src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' >&nbsp;Adicionar</button>
 														</td>
 													</tr>							
 													<tr height='5'><td>&nbsp;</td></tr>
 													<tr><td  align='center'>
-															<button type='button' onClick='javascript:rem()'><img src='calendar/templates/celepar/images/rem.png' style='vertical-align: middle;' >&nbsp;Remover</button>
+															<button type='button' onClick='javascript:rem()'><img src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/images/rem.png' style='vertical-align: middle;' >&nbsp;Remover</button>
 														</td>
 													</tr>
@@ -4574,5 +4651,5 @@
 										</tr>
 										</table>
-									<script src='calendar/templates/celepar/js/edit.js' type='text/javascript'></script>				
+									<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/edit.js' type='text/javascript'></script>				
 									"
 						);
@@ -4622,6 +4699,6 @@
 											'<tr>'.
 											'<td width="25%"><br>'.	
-											'<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/celepar/images/add.png" style="vertical-align: middle;" >&nbsp;'.lang("Add").'</button>'.
-											'&nbsp;&nbsp;<button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/celepar/images/rem.png" style="vertical-align: middle;" >&nbsp;'.lang("Remove").'</button>'.
+											'<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" >&nbsp;'.lang("Add").'</button>'.
+											'&nbsp;&nbsp;<button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" >&nbsp;'.lang("Remove").'</button>'.
 											'<br><br>&nbsp;&nbsp;<b>'.lang("Event's participants").'</b><br>'.
 											'	<select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'.
@@ -4631,5 +4708,5 @@
 											'<td valign="bottom">'.
 											'	'.lang("Organization").': '.
-											'	<select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\');">'.$combo_org.'</select>'.
+										//	'	<select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\');">'.$combo_org.'</select>'.
 											'	<br>'.
 											'	<font color="red"><span id="cal_span_searching">&nbsp;</span></font>'.									
@@ -4643,10 +4720,10 @@
 											'<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'.
 											'<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'.		
-											"<script src='calendar/templates/celepar/js/edit_exmail.js' type='text/javascript'></script>" .
+											"<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/edit_exmail.js' type='text/javascript'></script>" .
 											$load_lang_vars.																			
 											"<script src='".$module_name."/js/connector.js' type='text/javascript'></script>".
 											"<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".											
 											"<script type='text/javascript'>" .
-											"var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\')',1000);". 
+										//	"var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\')',1000);". 
 											"</script> "
 								);
@@ -4656,8 +4733,8 @@
 						$var['participants']['data'] .= '<a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" .
 							" of this system").'" name="a_ext_participants" onClick="javascript:showExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants"><b>'.lang("Inform").' '.lang("external participants").'</b>&nbsp;<img align="top" ' .
-							'src="calendar/templates/celepar/images/sent.gif"></a><table id="tbl_ext_participants" width="100%" border="0" style="display:none">'.
+							'src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif"></a><table id="tbl_ext_participants" width="100%" border="0" style="display:none">'.
 							'<tr>'.
 							'<td>'.	
-							'&nbsp;&nbsp;<b>'.lang("external participants").'</b>&nbsp;<img align="top" src="calendar/templates/celepar/images/sent.gif">' .
+							'&nbsp;&nbsp;<b>'.lang("external participants").'</b>&nbsp;<img align="top" src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif">' .
 							'&nbsp;&nbsp;<a title="'.lang("Close").'" name="b_ext_participants" onClick="javascript:hideExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants">['.lang("Close").']</a>&nbsp;'.														
 							'</td>'.
