Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Mehow

Calendário de Eventos

Recommended Posts

Pessoal estou abrindo esse tópico para pedir ajuda em um calendário... já procurei no google mas não acho, só acho datepicker :S

 

preciso fazer um calendário como nesse exemplo

http://www.paroquiacolina.com/2010/

 

alguém sabe onde tem algum para download?

 

vou ter uma área administrativa onde cadastrarei os eventos, daí no calendário ficará marcada a data do evento que cadastrei e quando clicar nela irá para uma página com mais detalhes

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenho impressão que não seja em javascript...

Acho que talvez tenha uma base PHP

Talvez devesse procurar ajuda-lá...

mesmo assim PHP - date()

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qndo precisei de algo parecido com isso, usei essa classe aqui, para gerar o calendário para mim.

E então, alterando o fonte dela, fiz links, conexão com o banco e tal..

http://www.cascade.org.uk/software/php/calendar/

 

source:

http://www.cascade.org.uk/software/php/calendar/Calendar.txt

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu prefiro a livraria YUI(Yahoo User Interface).

YUI Calendar.

 

Com um pouquinho de codigo, voce pode obter fantasticos resultados. Podendo alimentar o calendario do PHP, JSON ou XHR sem muito esforco.

 

Flw

Compartilhar este post


Link para o post
Compartilhar em outros sites

Qndo precisei de algo parecido com isso, usei essa classe aqui, para gerar o calendário para mim.

E então, alterando o fonte dela, fiz links, conexão com o banco e tal..

http://www.cascade.org.uk/software/php/calendar/

 

source:

http://www.cascade.org.uk/software/php/calendar/Calendar.txt

 

Legal esse calendário, bem fácil de personalizar. o complicado é que ele foi feito usando orientação a objetos, não entendo nada. Pode me explicar como cadastro data nele?

Vou ter que fazer um controle e cadastrar uma data no calendário

 

 

Eu prefiro a livraria YUI(Yahoo User Interface).

YUI Calendar.

Com um pouquinho de codigo, voce pode obter fantasticos resultados. Podendo alimentar o calendario do PHP, JSON ou XHR sem muito esforco.

 

Flw

 

bonito o calendário, da para manipulá-lo só com PHP ou tem que usar Ajax?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pode me explicar como cadastro data nele?

 

Tá ai a questão, você não vai cadastrar nada nele. E sim num banco de dados.

 

Faça com que os dias te gerem links.. e apartir disso, defina os teus Controllers, para inserir entradas no banco, com a data selecionada no calendário.

 

Algo do tipo:

Table evento:

id, nome, local, descricao, data

 

e então, você cadastra com base no dia selecionado no calendário. Bem simples.

Dá para fazer 'manualmente', gerando os dias com a função date() do php, e outras mais.. depende do qnto você quer estudar.

Compartilhar este post


Link para o post
Compartilhar em outros sites

 

Pode me explicar como cadastro data nele?

 

Tá ai a questão, você não vai cadastrar nada nele. E sim num banco de dados.

 

Faça com que os dias te gerem links.. e apartir disso, defina os teus Controllers, para inserir entradas no banco, com a data selecionada no calendário.

 

Algo do tipo:

Table evento:

id, nome, local, descricao, data

 

e então, você cadastra com base no dia selecionado no calendário. Bem simples.

Dá para fazer 'manualmente', gerando os dias com a função date() do php, e outras mais.. depende do qnto você quer estudar.

 

Cara foi mais fácil do que pensei!

show de bola essa classe, e lá no site já tem tudo explicado... pensei que ia ser um bixo de 7 cabeças pegar as datas no BD para marcar no calendário... mas foi fácil d+

 

só precisei acrescentar um pequeno código na função que pega a data

$sql = mysql_query("SELECT * from eventos");
		while($row  = mysql_fetch_array($sql)){
		
		$id = $row['id'];
		$data = $row['data'];
		$dia = substr($data,8,2);
		$mes = substr($data,5,2);
		$ano = substr($data,0,4);
		
			if ($day == $dia && $month == $mes && $year == $ano)
			{
				$link = 'evento.php&data='.$data;
			}
		
		}
        return $link;

Valew pela ajuda!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sim,

 

Voce pode manipular o calendario utilizando PHP. Voce pode passar para o calendario um array com datas e qualquer outra coisa. Tambem e possivel sem muito esforco utilizar JSON ou XHR.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sim,

 

Voce pode manipular o calendario utilizando PHP. Voce pode passar para o calendario um array com datas e qualquer outra coisa. Tambem e possivel sem muito esforco utilizar JSON ou XHR.

 

Galera fiz o calendário, deu certo e tal.... agora preciso fazer uma coisa q nem sei como

 

olhem o calendário

http://www.paroquiacolina.com/2010/index.php

 

o que tenho que fazer é ao colocar o mouse em cima da data vai abrir uma pequena janela escrito o evento daquela data

 

alguém sabe me explicar o que tenho que fazer ou algum script?

Compartilhar este post


Link para o post
Compartilhar em outros sites

deixa a data como link...

Dai quando onmouseover abre chama uma div com o escrito para a data com a posição calculada apartir da posição do mouse...

dai onmouseout muda o display dessa div para none...

Compartilhar este post


Link para o post
Compartilhar em outros sites

achei um código para fazer o que eu queria, só não sei como aplicar ao calendário para pegar informação só da data que eu quero mostrar

 

vo ir tentando aqui, qualquer coisa peço ajuda

 

 <script>
 function mostraLayer(obj){                               
  var div = document.getElementById(obj).style;                                
  div.display = "block";                        
  }                        
  function escondeLayer(obj){                                
  var div = document.getElementById(obj).style;                                
  div.display = "none";                       
   }               
    </script>               
     <style>                        
	 #divLayer{                                
	 position: absolute;                                
	 top: 30px;                                
	 left: 50px;                                
	 border: solid 1px #658DA7;                               
	 width: 200px;                               
	 height: 150px;                                
	 display: none;                                
	 background-color: #EEEEEE;                                
	 padding: 10px;                        
	 }                
     </style>
</head>

<body>
    <div>                       
    <a href="#" onmouseover="mostraLayer('divLayer');" onmouseout="escondeLayer('divLayer');">Nosso forum!</a>                
   </div>                
   <div id="divLayer" name="nm_divLayer">                       
    Seria isso?                
    </div>
</body>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Seria isso mesmo...

Mas coloque um onmousemove e faça a posição dessa div se adequar a posição do mouse do usuario...

assim cria um efeito bem legal...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Seria isso mesmo...

Mas coloque um onmousemove e faça a posição dessa div se adequar a posição do mouse do usuario...

assim cria um efeito bem legal...

 

mas como faço para colocar o script para funcionar no calendário?

tentei colocar na parte que retorna o link na classe do calendário mas não deu certo

 

 

calendário.php

<?

// PHP Calendar Class Version 1.4 (5th March 2001)
//  
// Copyright David Wilkinson 2000 - 2001. All Rights reserved.
// 
// This software may be used, modified and distributed freely
// providing this copyright notice remains intact at the head 
// of the file.
//
// This software is freeware. The author accepts no liability for
// any loss or damages whatsoever incurred directly or indirectly 
// from the use of this script. The author of this software makes 
// no claims as to its fitness for any purpose whatsoever. If you 
// wish to use this software you should first satisfy yourself that 
// it meets your requirements.
//
// URL:   http://www.cascade.org.uk/software/php/calendar/
// Email: davidw@cascade.org.uk


class Calendar
{
    /*
        Constructor for the Calendar class
    */
    function Calendar()
    {
    }
    
    
    /*
        Get the array of strings used to label the days of the week. This array contains seven 
        elements, one for each day of the week. The first entry in this array represents Sunday. 
    */
    function getDayNames()
    {
        return $this->dayNames;
    }
    

    /*
        Set the array of strings used to label the days of the week. This array must contain seven 
        elements, one for each day of the week. The first entry in this array represents Sunday. 
    */
    function setDayNames($names)
    {
        $this->dayNames = $names;
    }
    
    /*
        Get the array of strings used to label the months of the year. This array contains twelve 
        elements, one for each month of the year. The first entry in this array represents January. 
    */
    function getMonthNames()
    {
        return $this->monthNames;
    }
    
    /*
        Set the array of strings used to label the months of the year. This array must contain twelve 
        elements, one for each month of the year. The first entry in this array represents January. 
    */
    function setMonthNames($names)
    {
        $this->monthNames = $names;
    }
    
    
    
    /* 
        Gets the start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
      function getStartDay()
    {
        return $this->startDay;
    }
    
    /* 
        Sets the start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
    function setStartDay($day)
    {
        $this->startDay = $day;
    }
    
    
    /* 
        Gets the start month of the year. This is the month that appears first in the year
        view. January = 1.
    */
    function getStartMonth()
    {
        return $this->startMonth;
    }
    
    /* 
        Sets the start month of the year. This is the month that appears first in the year
        view. January = 1.
    */
    function setStartMonth($month)
    {
        $this->startMonth = $month;
    }
    
    
    /*
        Return the URL to link to in order to display a calendar for a given month/year.
        You must override this method if you want to activate the "forward" and "back" 
        feature of the calendar.
        
        Note: If you return an empty string from this function, no navigation link will
        be displayed. This is the default behaviour.
        
        If the calendar is being displayed in "year" view, $month will be set to zero.
    */
    function getCalendarLink($month, $year)
    {
        return "";
    }
    
    /*
        Return the URL to link to  for a given date.
        You must override this method if you want to activate the date linking
        feature of the calendar.
        
        Note: If you return an empty string from this function, no navigation link will
        be displayed. This is the default behaviour.
    */
    function getDateLink($day, $month, $year)
    {
        return "";
    }


    /*
        Return the HTML for the current month
    */
    function getCurrentMonthView()
    {
        $d = getdate(time());
        return $this->getMonthView($d["mon"], $d["year"]);
    }
    

    /*
        Return the HTML for the current year
    */
    function getCurrentYearView()
    {
        $d = getdate(time());
        return $this->getYearView($d["year"]);
    }
    
    
    /*
        Return the HTML for a specified month
    */
    function getMonthView($month, $year)
    {
        return $this->getMonthHTML($month, $year);
    }
    

    /*
        Return the HTML for a specified year
    */
    function getYearView($year)
    {
        return $this->getYearHTML($year);
    }
    
    
    
    /********************************************************************************
    
        The rest are private methods. No user-servicable parts inside.
        
        You shouldn't need to call any of these functions directly.
        
    *********************************************************************************/


    /*
        Calculate the number of days in a month, taking into account leap years.
    */
    function getDaysInMonth($month, $year)
    {
        if ($month < 1 || $month > 12)
        {
            return 0;
        }
   
        $d = $this->daysInMonth[$month - 1];
   
        if ($month == 2)
        {
            // Check for leap year
            // Forget the 4000 rule, I doubt I'll be around then...
        
            if ($year%4 == 0)
            {
                if ($year%100 == 0)
                {
                    if ($year%400 == 0)
                    {
                        $d = 29;
                    }
                }
                else
                {
                    $d = 29;
                }
            }
        }
    
        return $d;
    }


    /*
        Generate the HTML for a given month
    */
    function getMonthHTML($m, $y, $showYear = 1)
    {
        $s = "";
        
        $a = $this->adjustDate($m, $y);
        $month = $a[0];
        $year = $a[1];        
        
    	$daysInMonth = $this->getDaysInMonth($month, $year);
    	$date = getdate(mktime(12, 0, 0, $month, 1, $year));
    	
    	$first = $date["wday"];
    	$monthName = $this->monthNames[$month - 1];
    	
    	$prev = $this->adjustDate($month - 1, $year);
    	$next = $this->adjustDate($month + 1, $year);
    	
    	if ($showYear == 1)
    	{
    	    $prevMonth = $this->getCalendarLink($prev[0], $prev[1]);
    	    $nextMonth = $this->getCalendarLink($next[0], $next[1]);
    	}
    	else
    	{
    	    $prevMonth = "";
    	    $nextMonth = "";
    	}
    	
    	$header = $monthName . (($showYear > 0) ? " " . $year : "");
    	
    	$s .= "<table class=\"calendar\" cellpadding=\"5\" cellspacing=\"5\" border=0>\n";
    	$s .= "<tr>\n";
    	$s .= "<td align=\"center\" valign=\"top\">" . (($prevMonth == "") ? " " : "<a href=\"$prevMonth\"><img src=icones/esq.png border=0 alt=\"Mês Anterior\"></a>")  . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\" colspan=\"5\">$header</td>\n"; 
    	$s .= "<td align=\"center\" valign=\"top\">" . (($nextMonth == "") ? " " : "<a href=\"$nextMonth\"><img src=icones/dir.png border=0 alt=\"Próximo Mês\"></a>")  . "</td>\n";
    	$s .= "</tr>\n";
    	
    	$s .= "<tr>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\" >" . $this->dayNames[($this->startDay)%7] . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+1)%7] . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+2)%7] . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+3)%7] . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+4)%7] . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+5)%7] . "</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+6)%7] . "</td>\n";
    	$s .= "</tr>\n";
    	
    	// We need to work out what date to start at so that the first appears in the correct column
    	$d = $this->startDay + 1 - $first;
    	while ($d > 1)
    	{
    	    $d -= 7;
    	}

        // Make sure we know when today is, so that we can use a different CSS style
        $today = getdate(time());
    	
    	while ($d <= $daysInMonth)
    	{
    	    $s .= "<tr>\n";       
    	    
    	    for ($i = 0; $i < 7; $i++)
    	    {
        	    $class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar";
    	        $s .= "<td class=\"$class\" align=\"right\" valign=\"top\">";       
    	        if ($d > 0 && $d <= $daysInMonth)
    	        {
    	            $link = $this->getDateLink($d, $month, $year);
    	            $s .= (($link == "") ? $d : "<a href=\"$link\">$d</a>");
    	        }
    	        else
    	        {
    	            $s .= " ";
    	        }
      	        $s .= "</td>\n";       
        	    $d++;
    	    }
    	    $s .= "</tr>\n";    
    	}
    	
    	$s .= "</table>\n";
    	
    	return $s;  	
    }
    
    
    /*
        Generate the HTML for a given year
    */
    function getYearHTML($year)
    {
        $s = "";
    	$prev = $this->getCalendarLink(0, $year - 1);
    	$next = $this->getCalendarLink(0, $year + 1);
        
        $s .= "<table class=\"calendar\" border=\"0\">\n";
        $s .= "<tr>";
    	$s .= "<td align=\"center\" valign=\"top\" align=\"left\">" . (($prev == "") ? " " : "<a href=\"$prev\"><<</a>")  . "</td>\n";
        $s .= "<td class=\"calendarHeader\" valign=\"top\" align=\"center\">" . (($this->startMonth > 1) ? $year . " - " . ($year + 1) : $year) ."</td>\n";
    	$s .= "<td align=\"center\" valign=\"top\" align=\"right\">" . (($next == "") ? " " : "<a href=\"$next\">>></a>")  . "</td>\n";
        $s .= "</tr>\n";
        $s .= "<tr>";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(0 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(1 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(2 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "</tr>\n";
        $s .= "<tr>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(3 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(4 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(5 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "</tr>\n";
        $s .= "<tr>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(6 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(7 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(8 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "</tr>\n";
        $s .= "<tr>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(9 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(10 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(11 + $this->startMonth, $year, 0) ."</td>\n";
        $s .= "</tr>\n";
        $s .= "</table>\n";
        
        return $s;
    }

    /*
        Adjust dates to allow months > 12 and < 0. Just adjust the years appropriately.
        e.g. Month 14 of the year 2001 is actually month 2 of year 2002.
    */
    function adjustDate($month, $year)
    {
        $a = array();  
        $a[0] = $month;
        $a[1] = $year;
        
        while ($a[0] > 12)
        {
            $a[0] -= 12;
            $a[1]++;
        }
        
        while ($a[0] <= 0)
        {
            $a[0] += 12;
            $a[1]--;
        }
        
        return $a;
    }

    /* 
        The start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
    var $startDay = 0;

    /* 
        The start month of the year. This is the month that appears in the first slot
        of the calendar in the year view. January = 1.
    */
    var $startMonth = 1;

    /*
        The labels to display for the days of the week. The first entry in this array
        represents Sunday.
    */
    var $dayNames = array("D", "S", "T", "Q", "Q", "S", "S");
    
    /*
        The labels to display for the months of the year. The first entry in this array
        represents January.
    */
    var $monthNames = array("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho",
                            "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
                            
                            
    /*
        The number of days in each month. You're unlikely to want to change this...
        The first entry in this array represents January.
    */
    var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    
}


class MyCalendar extends Calendar
{
    function getDateLink($day, $month, $year)
    {
      
        $link = "";
		$path_local = "padrao.php";
		include("db.php");
		
		$sql = mysql_query("SELECT * from eventos");
		while($row  = mysql_fetch_array($sql)){
		
		$id = $row['id'];
		$data = $row['data'];
		$dia = substr($data,8,2);
		$mes = substr($data,5,2);
		$ano = substr($data,0,4);
		$tipo = $row['tipo'];
		
			if ($day == $dia && $month == $mes && $year == $ano)
			{
				$link = 'index.php?xvar=eventos&data='.$data;
			}
			
			
			if($day == $dia && $month == $mes && $year == $ano && $tipo == "Notícias e Acontecimentos")
			{
				$link = 'index.php?xvar=acontecimentos&data='.$data;
			}
			
		
		}
        return $link;
    }
	
	 function getCalendarLink($month, $year)
    {
        // Redisplay the current page, but with some parameters
        // to set the new month and year
        $s = getenv('SCRIPT_NAME');
        return "$s?month=$month&year=$year";
    }
}



?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Em vez de exibir a data como por exemplo

echo $data
exiba assim

echo '<a href="#" onmouseover="getElementById('."'caixadia"."$data"."').style.display = ''".'
onmouseout="getElementById('."'caixadia"."$data"."').style.display = 'none'".'
onmousemove="getElementById('."'caixadia"."$data"."')=event.clientY+15;getElementById("."'caixadia"."$data"."')=event.clientX+15;".'">';

Dai cria uma div com o id caixadia20 por exemplo... quando você passar o mouse em cima do dia 20 vai exibir essa div dai...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.