Registration of dates from the calendar

Asked

Viewed 105 times

0

I am trying to make a record of recurrence of dates for an event, I have this calendar: https://procurandooquefazer.com.br/data_calendario/

I wanted it to be possible to click on each date, preferably who is creating the event, and he would select several dates, to make a recurrence, and that recurrence be registered in the database, I need it saved, day/month/Year, I even tried to put Checkbox, but when you leave for jQuery, I can’t make the array work.

Codes:

<?php
function num($num){
    return ($num < 10) ? '0'.$num : $num;
}
function diasMeses(){
    $retorno = array();
    for($i = 1; $i<=12;$i++){
        $retorno[$i] = cal_days_in_month(CAL_GREGORIAN, $i, date('Y'));
    }
    return $retorno;
}
function montaCalendario(){
    $daysWeek = array(
        'Sun',
        'Mon',
        'Tue',
        'Wed',
        'Thu',
        'Fri',
        'Sat'
    );
    $diasSemana = array(
        'Dom',
        'Seg',
        'Ter',
        'Qua',
        'Qui',
        'Sex',
        'Sab'
    );
    $arrayMes = array(
        1 => 'Janeiro',
        2 => 'Fevereiro',
        3 => 'Março',
        4 => 'Abril',
        5 => 'Maio',
        6 => 'Junho',
        7 => 'Julho',
        8 => 'Agosto',
        9 => 'Setembro',
        10 => 'Outubro',
        11 => 'Novembro',
        12 => 'Dezembro'
    );
    $diasMeses = diasMeses();
    $arrayRetorno = array();
    for($i =1; $i <= 12; $i++){
        $arrayRetorno[$i] = array();
        for($n=1; $n<= $diasMeses[$i]; $n++){
            $dayMonth = gregoriantojd($i, $n, date('Y'));
            $weekMonth = substr(jddayofweek($dayMonth, 1),0,3);
            if($weekMonth == 'Mun') $weekMonth = 'Mon';
            $arrayRetorno[$i][$n] = $weekMonth;
        }
    }
    echo '<a href="#" id="volta"><i class="fa fa-angle-double-left"></i></a><a href="#" id="vai"><i class="fa fa-angle-double-right"></i></a>';
    echo '<table border="0" width="100%">';
    foreach($arrayMes as $num => $mes){
        echo '<tbody id="mes_'.$num.'" class="mes">';
        echo '<tr class="mes_title">
<td colspan="7"><strong>'.$mes.'</strong></td></tr>';
        echo '<tr class="dias_title">';
        foreach($diasSemana as $i => $day){
            echo '<td><strong>'.$day.'</strong></td>';
        }
        echo '</tr><tr>';
        $y = 0;
        foreach($arrayRetorno[$num] as $numero => $dia){
            $y++;
            if($numero == 1){
                $qtd = array_search($dia, $daysWeek);
                for($i=1; $i<=$qtd; $i++){
                    echo '<td></td>';
                    $y+=1;
                }
            }
            $month = num($num);
            echo '<td class="dia_'.$numero.'">
<strong>'.$numero.'</strong></td>';
            if($y == 7){
                $y=0;
                echo '</tr><tr>';
            }
        }
        echo '</tr></tbody>';
    }
    echo '</table>';
}
?>
  • Share your code, otherwise it’s hard

  • The calendar you’re using, you took the basis of Lucas Silva’s classes?

  • Yes, it is in php, only thing that is not there are his events, because I will not need, this calendar, as it is simple, I saw that would serve only for me to do as recurrence.

  • jQuery already has on the page

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.