Configurar dias de agendamento
fala pessoal eu aqui de novo kkk
consegui achar um tutorial de como criar o calendario fiz algumas modificaçoes
porem agora eu quero fazer o seguinte quero definir os dias que os serviços seram apresentados nos dias
tipo tenho segunda terça quarta quinta sexta sabado e domingo ai esses dias seram inseridos no banco
como posso fazer uma verificação no codigo
<?php
// What is the first day of the month in question?
function build_calendar($month, $year) {
$Read = new Read;
$Read->FullRead("SELECT * FROM " . DB_AGENDAMENTO . " WHERE MONTH(date) =:month AND YEAR(date)=:year","month={$month}&year={$year}");
$bookings = array();
if($Read->getResult()):
if($Read->getRowCount() > 0):
while($row = $Read->getResult()):
$bookings[] = $row['date'];
endwhile;
endif;
endif;
// Create array containing abbreviations of days of week.
// $daysOfWeek = array('Sunday', 'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// Qual é o primeiro dia do mês em questão?
$firstDayOfMonth = mktime(0,0,0,$month,1,$year);
// Quantos dias este mês contém?
$numberDays = date('t',$firstDayOfMonth);
// Recuperar algumas informações sobre o primeiro dia do
// mês em questão.
$dateComponents = getdate($firstDayOfMonth);
// What is the name of the month in question?
$monthName = $dateComponents['month'];
// What is the index value (0-6) of the first day of the
// month in question.
$dayOfWeek = $dateComponents['wday'];
// Create the table tag opener and day headers
$datetoday = date('Y-m-d');
$calendar = "<table class='table table-bordered'>";
$calendar .= "<center><h2>$monthName $year</h2>";
// se a data month < que a data atual então o botão sera desativado
if($month <=> date('m')):
$calendar.= "<a class='btn btn-xs btn-primary' href=". BASE ."/index/month/".date('m', mktime(0, 0, 0, $month-1, 1, $year))."/year/".date('Y', mktime(0, 0, 0, $month-1, 1, $year)).">Previous Month</a> ";
else:
$calendar.= "<a class='btn btn-xs btn-primary'>Previous Month</a>";
endif;
$calendar.= " <a href=". BASE ." class='btn btn-xs btn-primary' data-month='".date('m')."' data-year='".date('Y')."'>Current Month</a> ";
$calendar.= "<a href='". BASE ."/index/month/".date('m', mktime(0, 0, 0, $month+1, 1, $year))."/year/".date('Y', mktime(0, 0, 0, $month + 1, 1, $year))."' class='btn btn-xs btn-primary'>Next Month</a></center><br>";
$calendar .= "<tr>";
// Create the calendar headers
foreach(getSemana() as $day):
$calendar .= "<th class='header'>$day</th>";
endforeach;
// Cria o resto do calendário
// Inicia o contador de dias, começando com o 1º.
$currentDay = 1;
$calendar .= "</tr><tr>";
// A variável $dayOfWeek é usada para
// assegura que o calendário
// display consiste em exatamente 7 colunas.
if($dayOfWeek > 0):
for($k = 0; $k < $dayOfWeek; $k++):
$calendar .= "<td class='empty'></td>";
endfor;
endif;
$month = str_pad($month, 2, "0", STR_PAD_LEFT);
while ($currentDay <= $numberDays):
//Sétima coluna (sábado) atingida. Inicie uma nova linha.
if ($dayOfWeek == 7):
$dayOfWeek = 0;
$calendar .= "</tr><tr>";
endif;
$currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT);
$date = "$year-$month-$currentDayRel"; //volta para a data atual
$dayname = strtolower(date('l', strtotime($date)));
$eventNum = 0;
$appointment_date = date('Y-m-d', strtotime($appointment_date . ' +1 day'));
$day_id = date('w',strtotime($appointment_date));
// var_dump($day_id);
$today = $date == date('Y-m-d') ? "today" : "";
if($date < date('Y-m-d')):
$calendar.="<td><h4>$currentDay</h4> <button class='btn-danger-no '></button>";
else:
$calendar.="<td class='$today'><h4>$currentDay</h4> <a href=".BASE."/book/date/".$date." class='btn btn-success btn-xs'>Book</a>";
endif;
$calendar .="</td>";
//Increment counters
$currentDay++;
$dayOfWeek++;
endwhile;
//Complete the row of the last week in month, if necessary
if ($dayOfWeek != 7):
$remainingDays = 7 - $dayOfWeek;
for($l=0; $l < $remainingDays; $l++):
$calendar .= "<td class='empty'></td>";
endfor;
endif;
$calendar .= "</tr>";
$calendar .= "</table>";
return $calendar;
}Discussão (0)
Carregando comentários...