function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
$mes_pt = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
//$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
$title = htmlentities(ucfirst($mes_pt[(int)$month])).' '.$year;
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month"><h1><center><strong>'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</strong></center></h1></caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
//foreach($day_names as $d)
//$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Domingo</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Segunda</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Terça</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quarta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quinta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sexta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sábado</strong></th>";
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
$link = mysqli_connect("192.168.0.26", "centro","qQQ!000p","centrodb");
$link->set_charset('utf8');
$sql = "SELECT arrachar FROM centrodb.marcacaolar";
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$dado .= str_replace(","," ",$row['arrachar'])." ";
}
$dado = explode(" ", trim($dado));
$dados1 = array();
$data_atual = null;
foreach ($dado as $key => $value) {
$data1 = date('Y-m-d', strtotime($value));
$data2 = $value;
if (strtotime($data1) == strtotime($data2)) {
$data_atual = $value;
}else{
$dados1[$data_atual][] = $value;
}
}
?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
$marcado_data = "";
$dados2 = array();
foreach($dados1 as $item => $key){
if($item == "$year-$month-$day"){
$marcado_data = "checked";
$dados2 = $key;
}
}
if(strtotime("$year-$month-$day") <= strtotime(date("Y-m-d", strtotime("+1 day")))){
$disabled = "disabled";
}else{
$disabled = "";
}
$marcado_pequeno =$marcado_almoco =$marcado_dieta =$marcado_lanche =$marcado_jantar =$marcado_jantardie =$marcado_ceia =$marcado_pequeno_qtd =$marcado_almoco_qtd =$marcado_dieta_qtd =$marcado_lanche_qtd =$marcado_jantar_qtd =$marcado_jantardie_qtd =$marcado_ceia_qtd ='';
$color='#FFFFFF';
if(in_array("Peq_Almoço",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_pequeno = 'checked';
}
if(in_array("Almoço",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_almoco = 'checked';
}
if(in_array("Almoço_(Dieta)",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_dieta = 'checked';
}
if(in_array("Lanche",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_lanche = 'checked';
}
if(in_array("Jantar",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantar = 'checked';
}
if(in_array("Jantar_(Dieta)",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantardie = 'checked';
}
if(in_array("Ceia",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_ceia = 'checked';
}
if($marcado_pequeno == 'checked'){
$marcado_pequeno_qtd =$dados2[array_search("Peq_Almoço",$dados2)+1];
}
if($marcado_almoco == 'checked'){
$marcado_almoco_qtd =$dados2[array_search("Almoço",$dados2)+1];
}
if($marcado_dieta == 'checked'){
$marcado_dieta_qtd =$dados2[array_search("Almoço_(Dieta)",$dados2)+1];
}
if($marcado_lanche == 'checked'){
$marcado_lanche_qtd =$dados2[array_search("Lanche",$dados2)+1];
}
if($marcado_jantar == 'checked'){
$marcado_jantar_qtd =$dados2[array_search("Jantar",$dados2)+1];
}
if($marcado_jantardie == 'checked'){
$marcado_jantardie_qtd =$dados2[array_search("Jantar_(Dieta)",$dados2)+1];
}
if($marcado_ceia == 'checked'){
$marcado_ceia_qtd =$dados2[array_search("Ceia",$dados2)+1];
}
$calendar .= "<td<td bgcolor='$color' data-semana=''><font size='2px'/>
<input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day' $marcado_data $disabled> <strong style='color:#5ca2df'>$year$day'>$year-$month-$day <br />
<div style='width:60%;position:relative;float:left'><input <div>
<input type='checkbox' class='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço' $marcado_pequeno $disabled> <strong style='color: #000000'>Peqvalue='Peq_Almoço'>Peq. Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input<div><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço' $marcado_almoco $disabled> <strong style='color: #000000'>Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd' style='width:65px; height:
22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoC]' value='Almoço_(Dieta)' $marcado_dieta $disabled> <strong style='color:
#000000'>Almoço (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd2]' value='$marcado_dieta_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoD]' value='Lanche' $marcado_lanche $disabled> <strong style='color: #000000'>Lanche</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd3]' value='$marcado_lanche_qtd' style='width:65px; height: 22px' /><br /> </div><div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoE]' value='Jantar' $marcado_jantar $disabled> <strong style='color: #000000'>Jantar</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd4]' value='$marcado_jantar_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input<input type='checkbox' name='arrachar[$year, $month, $day][opcaoF]' value='Jantar_(Dieta)' $marcado_jantardie $disabled> <strong style='color: #000000'>Jantar (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd5]' value='$marcado_jantardie_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox'class='checkbox1' name='arrachar[$year, $month, $day][opcaoG]' value='Ceia' $marcado_ceia $disabled> <strong$day][opcaoB]' style='color: #000000'>Ceia</strong><value='Almoço'>Almoço</div> <div style='width:40%;position:relative;float:left'><input<div><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd6]' value='$marcado_ceia_qtd' style='width:65px; height: 22px' /></div> <br /> </font></center></td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">
</td>'; #remaining "empty" days
return $calendar."</tr>\n</table>\n";
}
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
$day][Qtd1]' /value='$marcado_almoco_qtd'/Monta o calendário
if(isset($_POST["data"])){
?>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) =<br explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">div>
</form>
<?php } ?>td>
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
$mes_pt = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
//$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
$title = htmlentities(ucfirst($mes_pt[(int)$month])).' '.$year;
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month"><h1><center><strong>'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</strong></center></h1></caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
//foreach($day_names as $d)
//$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Domingo</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Segunda</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Terça</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quarta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quinta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sexta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sábado</strong></th>";
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
$link = mysqli_connect("192.168.0.26", "centro","qQQ!000p","centrodb");
$link->set_charset('utf8');
$sql = "SELECT arrachar FROM centrodb.marcacaolar";
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$dado .= str_replace(","," ",$row['arrachar'])." ";
}
$dado = explode(" ", trim($dado));
$dados1 = array();
$data_atual = null;
foreach ($dado as $key => $value) {
$data1 = date('Y-m-d', strtotime($value));
$data2 = $value;
if (strtotime($data1) == strtotime($data2)) {
$data_atual = $value;
}else{
$dados1[$data_atual][] = $value;
}
}
?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
$marcado_data = "";
$dados2 = array();
foreach($dados1 as $item => $key){
if($item == "$year-$month-$day"){
$marcado_data = "checked";
$dados2 = $key;
}
}
if(strtotime("$year-$month-$day") <= strtotime(date("Y-m-d", strtotime("+1 day")))){
$disabled = "disabled";
}else{
$disabled = "";
}
$marcado_pequeno =$marcado_almoco =$marcado_dieta =$marcado_lanche =$marcado_jantar =$marcado_jantardie =$marcado_ceia =$marcado_pequeno_qtd =$marcado_almoco_qtd =$marcado_dieta_qtd =$marcado_lanche_qtd =$marcado_jantar_qtd =$marcado_jantardie_qtd =$marcado_ceia_qtd ='';
$color='#FFFFFF';
if(in_array("Peq_Almoço",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_pequeno = 'checked';
}
if(in_array("Almoço",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_almoco = 'checked';
}
if(in_array("Almoço_(Dieta)",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_dieta = 'checked';
}
if(in_array("Lanche",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_lanche = 'checked';
}
if(in_array("Jantar",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantar = 'checked';
}
if(in_array("Jantar_(Dieta)",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantardie = 'checked';
}
if(in_array("Ceia",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_ceia = 'checked';
}
if($marcado_pequeno == 'checked'){
$marcado_pequeno_qtd =$dados2[array_search("Peq_Almoço",$dados2)+1];
}
if($marcado_almoco == 'checked'){
$marcado_almoco_qtd =$dados2[array_search("Almoço",$dados2)+1];
}
if($marcado_dieta == 'checked'){
$marcado_dieta_qtd =$dados2[array_search("Almoço_(Dieta)",$dados2)+1];
}
if($marcado_lanche == 'checked'){
$marcado_lanche_qtd =$dados2[array_search("Lanche",$dados2)+1];
}
if($marcado_jantar == 'checked'){
$marcado_jantar_qtd =$dados2[array_search("Jantar",$dados2)+1];
}
if($marcado_jantardie == 'checked'){
$marcado_jantardie_qtd =$dados2[array_search("Jantar_(Dieta)",$dados2)+1];
}
if($marcado_ceia == 'checked'){
$marcado_ceia_qtd =$dados2[array_search("Ceia",$dados2)+1];
}
$calendar .= "<td bgcolor='$color' data-semana=''><font size='2px'/>
<input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day' $marcado_data $disabled> <strong style='color:#5ca2df'>$year-$month-$day <br />
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço' $marcado_pequeno $disabled> <strong style='color: #000000'>Peq. Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço' $marcado_almoco $disabled> <strong style='color: #000000'>Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoC]' value='Almoço_(Dieta)' $marcado_dieta $disabled> <strong style='color: #000000'>Almoço (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd2]' value='$marcado_dieta_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoD]' value='Lanche' $marcado_lanche $disabled> <strong style='color: #000000'>Lanche</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd3]' value='$marcado_lanche_qtd' style='width:65px; height: 22px' /><br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoE]' value='Jantar' $marcado_jantar $disabled> <strong style='color: #000000'>Jantar</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd4]' value='$marcado_jantar_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoF]' value='Jantar_(Dieta)' $marcado_jantardie $disabled> <strong style='color: #000000'>Jantar (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd5]' value='$marcado_jantardie_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoG]' value='Ceia' $marcado_ceia $disabled> <strong style='color: #000000'>Ceia</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd6]' value='$marcado_ceia_qtd' style='width:65px; height: 22px' /></div> <br /> </font></center></td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">
</td>'; #remaining "empty" days
return $calendar."</tr>\n</table>\n";
}
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
//Monta o calendário
if(isset($_POST["data"])){
?>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<td bgcolor='$color' data-semana=''><font size='2px'/>
<input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day'>$year-$month-$day <br />
<div>
<input type='checkbox' class='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço'>Peq. Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' />
<br />
</div>
<div>
<input type='checkbox' class='checkbox1' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço'>Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd'/>
<br />
</div>
</td>
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
$mes_pt = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
//$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
$title = htmlentities(ucfirst($mes_pt[(int)$month])).' '.$year;
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month"><h1><center><strong>'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</strong></center></h1></caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
//foreach($day_names as $d)
//$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Domingo</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Segunda</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Terça</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quarta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quinta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sexta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sábado</strong></th>";
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
$link = mysqli_connect("192.168.0.26", "centro","qQQ!000p","centrodb");
$link->set_charset('utf8');
$sql = "SELECT arrachar FROM centrodb.marcacaolar";
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$dado .= str_replace(","," ",$row['arrachar'])." ";
}
$dado = explode(" ", trim($dado));
$dados1 = array();
$data_atual = null;
foreach ($dado as $key => $value) {
$data1 = date('Y-m-d', strtotime($value));
$data2 = $value;
if (strtotime($data1) == strtotime($data2)) {
$data_atual = $value;
}else{
$dados1[$data_atual][] = $value;
}
}
?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= "<td><input'<td'.($classes id='firstCB{$year? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
$marcado_data = "";
$dados2 = array();
foreach($dados1 as $item => $key){
if($item == "$year-$month}-$day"){$day}' type='checkbox'
$marcado_data name='arrachar[$year,= $month,"checked"; $day][dia]'
$dados2 value='$year= $key;
}
}
if(strtotime("$year-$month-$day'>$year$day") <= strtotime(date("Y-$monthm-$dayd", <brstrtotime("+1 />day")))){
<div><input$disabled type='checkbox'= class='checkbox'"disabled"; name='arrachar[$year,
}else{ $month,
$disabled $day][OpcaoA]'= value='Peq_Almoço'>Peq.""; Almoço</div>
}
$marcado_pequeno <div><input=$marcado_almoco ref='firstCB=$marcado_dieta =$marcado_lanche =$marcado_jantar =$marcado_jantardie =$marcado_ceia =$marcado_pequeno_qtd =$marcado_almoco_qtd =$marcado_dieta_qtd =$marcado_lanche_qtd =$marcado_jantar_qtd =$marcado_jantardie_qtd =$marcado_ceia_qtd ='';
$color='#FFFFFF';
if(in_array("Peq_Almoço",$dados2)){$year
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_pequeno = 'checked';
}
if(in_array("Almoço",$dados2)){$month
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_almoco = 'checked';
}
if(in_array("Almoço_(Dieta)",$dados2)){$day}' min='0'
############################################################# oninput='this.value
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_dieta = Math.abs'checked';
}
if(this.valuein_array("Lanche",$dados2)'){ type='number'
############################################################# name='arrachar[$year,
### $monthaqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_lanche = 'checked';
}
if(in_array("Jantar",$dados2)){ $day][Qtd]'
############################################################# value='$marcado_pequeno_qtd'
### />aqui <brvocê /></div>cria a variável que vai dar cor ao elemento ###
<div><input############################################################# type='checkbox'
$color='gren'; class='checkbox1'
############################################################# name='arrachar[$year
$marcado_jantar = 'checked';
}
if(in_array("Jantar_(Dieta)",$dados2)){ $month
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantardie = 'checked';
}
if(in_array("Ceia",$dados2)){ $day][opcaoB]'
#############################################################
### value='Almoço'>Almoço</div>aqui <div><inputvocê ref='firstCBcria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_ceia = 'checked';
}
if($marcado_pequeno == 'checked'){$year
$marcado_pequeno_qtd =$dados2[array_search("Peq_Almoço",$dados2)+1];
}
if($marcado_almoco == 'checked'){$month
$marcado_almoco_qtd =$dados2[array_search("Almoço",$dados2)+1];
}
if($marcado_dieta == 'checked'){$day
$marcado_dieta_qtd =$dados2[array_search("Almoço_(Dieta)",$dados2)+1];
}' min='0'
if($marcado_lanche oninput='this.value== ='checked'){ Math.abs
$marcado_lanche_qtd =$dados2[array_search(this.value"Lanche",$dados2)'+1]; type='number'
} name='arrachar[$year
if($marcado_jantar == 'checked'){
$marcado_jantar_qtd =$dados2[array_search("Jantar",$dados2)+1]; $month
}
if($marcado_jantardie == 'checked'){
$marcado_jantardie_qtd =$dados2[array_search("Jantar_(Dieta)",$dados2)+1]; $day][Qtd1]'
}
if($marcado_ceia value='$marcado_almoco_qtd'/>== <br'checked'){ />
$marcado_ceia_qtd </div></td>=$dados2[array_search("Ceia",$dados2)+1];
}
$calendar .= "<td bgcolor='$color' data-semana=''><font size='2px'/>
<input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day' $marcado_data $disabled> <strong style='color:#5ca2df'>$year-$month-$day <br />
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço' $marcado_pequeno $disabled> <strong style='color: #000000'>Peq. Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço' $marcado_almoco $disabled> <strong style='color: #000000'>Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoC]' value='Almoço_(Dieta)' $marcado_dieta $disabled> <strong style='color: #000000'>Almoço (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd2]' value='$marcado_dieta_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoD]' value='Lanche' $marcado_lanche $disabled> <strong style='color: #000000'>Lanche</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd3]' value='$marcado_lanche_qtd' style='width:65px; height: 22px' /><br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoE]' value='Jantar' $marcado_jantar $disabled> <strong style='color: #000000'>Jantar</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd4]' value='$marcado_jantar_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoF]' value='Jantar_(Dieta)' $marcado_jantardie $disabled> <strong style='color: #000000'>Jantar (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd5]' value='$marcado_jantardie_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoG]' value='Ceia' $marcado_ceia $disabled> <strong style='color: #000000'>Ceia</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd6]' value='$marcado_ceia_qtd' style='width:65px; height: 22px' /></div> <br /> </font></center></td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">
</td>'; #remaining "empty" days
return $calendar."</tr>\n</table>\n";
}
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
//Monta o calendário
if(isset($_POST["data"])){
?>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
$calendar .= "<td><input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day'>$year-$month-$day <br />
<div><input type='checkbox' class='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço'>Peq. Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' /> <br /></div>
<div><input type='checkbox' class='checkbox1' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço'>Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd'/> <br /> </div></td>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
$mes_pt = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
//$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
$title = htmlentities(ucfirst($mes_pt[(int)$month])).' '.$year;
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month"><h1><center><strong>'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</strong></center></h1></caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
//foreach($day_names as $d)
//$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Domingo</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Segunda</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Terça</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quarta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quinta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sexta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sábado</strong></th>";
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
$link = mysqli_connect("192.168.0.26", "centro","qQQ!000p","centrodb");
$link->set_charset('utf8');
$sql = "SELECT arrachar FROM centrodb.marcacaolar";
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$dado .= str_replace(","," ",$row['arrachar'])." ";
}
$dado = explode(" ", trim($dado));
$dados1 = array();
$data_atual = null;
foreach ($dado as $key => $value) {
$data1 = date('Y-m-d', strtotime($value));
$data2 = $value;
if (strtotime($data1) == strtotime($data2)) {
$data_atual = $value;
}else{
$dados1[$data_atual][] = $value;
}
}
?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
$marcado_data = "";
$dados2 = array();
foreach($dados1 as $item => $key){
if($item == "$year-$month-$day"){
$marcado_data = "checked";
$dados2 = $key;
}
}
if(strtotime("$year-$month-$day") <= strtotime(date("Y-m-d", strtotime("+1 day")))){
$disabled = "disabled";
}else{
$disabled = "";
}
$marcado_pequeno =$marcado_almoco =$marcado_dieta =$marcado_lanche =$marcado_jantar =$marcado_jantardie =$marcado_ceia =$marcado_pequeno_qtd =$marcado_almoco_qtd =$marcado_dieta_qtd =$marcado_lanche_qtd =$marcado_jantar_qtd =$marcado_jantardie_qtd =$marcado_ceia_qtd ='';
$color='#FFFFFF';
if(in_array("Peq_Almoço",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_pequeno = 'checked';
}
if(in_array("Almoço",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_almoco = 'checked';
}
if(in_array("Almoço_(Dieta)",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_dieta = 'checked';
}
if(in_array("Lanche",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_lanche = 'checked';
}
if(in_array("Jantar",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantar = 'checked';
}
if(in_array("Jantar_(Dieta)",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_jantardie = 'checked';
}
if(in_array("Ceia",$dados2)){
#############################################################
### aqui você cria a variável que vai dar cor ao elemento ###
#############################################################
$color='gren';
#############################################################
$marcado_ceia = 'checked';
}
if($marcado_pequeno == 'checked'){
$marcado_pequeno_qtd =$dados2[array_search("Peq_Almoço",$dados2)+1];
}
if($marcado_almoco == 'checked'){
$marcado_almoco_qtd =$dados2[array_search("Almoço",$dados2)+1];
}
if($marcado_dieta == 'checked'){
$marcado_dieta_qtd =$dados2[array_search("Almoço_(Dieta)",$dados2)+1];
}
if($marcado_lanche == 'checked'){
$marcado_lanche_qtd =$dados2[array_search("Lanche",$dados2)+1];
}
if($marcado_jantar == 'checked'){
$marcado_jantar_qtd =$dados2[array_search("Jantar",$dados2)+1];
}
if($marcado_jantardie == 'checked'){
$marcado_jantardie_qtd =$dados2[array_search("Jantar_(Dieta)",$dados2)+1];
}
if($marcado_ceia == 'checked'){
$marcado_ceia_qtd =$dados2[array_search("Ceia",$dados2)+1];
}
$calendar .= "<td bgcolor='$color' data-semana=''><font size='2px'/>
<input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day' $marcado_data $disabled> <strong style='color:#5ca2df'>$year-$month-$day <br />
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço' $marcado_pequeno $disabled> <strong style='color: #000000'>Peq. Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço' $marcado_almoco $disabled> <strong style='color: #000000'>Almoço</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoC]' value='Almoço_(Dieta)' $marcado_dieta $disabled> <strong style='color: #000000'>Almoço (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd2]' value='$marcado_dieta_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoD]' value='Lanche' $marcado_lanche $disabled> <strong style='color: #000000'>Lanche</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd3]' value='$marcado_lanche_qtd' style='width:65px; height: 22px' /><br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoE]' value='Jantar' $marcado_jantar $disabled> <strong style='color: #000000'>Jantar</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd4]' value='$marcado_jantar_qtd' style='width:65px; height: 22px' /> <br /> </div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoF]' value='Jantar_(Dieta)' $marcado_jantardie $disabled> <strong style='color: #000000'>Jantar (Dieta)</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd5]' value='$marcado_jantardie_qtd' style='width:65px; height: 22px' /> <br /></div>
<div style='width:60%;position:relative;float:left'><input type='checkbox' name='arrachar[$year, $month, $day][opcaoG]' value='Ceia' $marcado_ceia $disabled> <strong style='color: #000000'>Ceia</strong></div> <div style='width:40%;position:relative;float:left'><input ref='firstCB{$year}{$month}{$day}' $disabled min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd6]' value='$marcado_ceia_qtd' style='width:65px; height: 22px' /></div> <br /> </font></center></td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">
</td>'; #remaining "empty" days
return $calendar."</tr>\n</table>\n";
}
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
//Monta o calendário
if(isset($_POST["data"])){
?>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
$mes_pt = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
//$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
$title = htmlentities(ucfirst($mes_pt[(int)$month])).' '.$year;
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month"><h1><center><strong>'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</strong></center></h1></caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
//foreach($day_names as $d)
//$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Domingo</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Segunda</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Terça</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quarta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quinta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sexta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sábado</strong></th>";
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
$sql = "SELECT arrachar FROM centrodb.marcacaolar";
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$dado .= str_replace(","," ",$row['arrachar'])." ";
}
$dado = explode(" ", trim($dado));
$dados1 = array();
$data_atual = null;
foreach ($dado as $key => $value) {
$data1 = date('Y-m-d', strtotime($value));
$data2 = $value;
if (strtotime($data1) == strtotime($data2)) {
$data_atual = $value;
}else{
$dados1[$data_atual][] = $value;
}
}
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
$calendar .= "<td><input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day'>$year-$month-$day <br />
<div><input type='checkbox' class='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço'>Peq. Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' /> <br /></div>
<div><input type='checkbox' class='checkbox1' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço'>Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd'/> <br /> </div></td>
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">
</td>'; #remaining "empty" days
return $calendar."</tr>\n</table>\n";
}
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
//Monta o calendário
if(isset($_POST["data"])){
?>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
$mes_pt = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
//$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
$title = htmlentities(ucfirst($mes_pt[(int)$month])).' '.$year;
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month"><h1><center><strong>'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</strong></center></h1></caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
//foreach($day_names as $d)
//$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Domingo</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Segunda</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Terça</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quarta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Quinta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sexta</strong></th>";
$calendar .= "<th bgcolor='black'><center><strong style='color: #FFFFFF'>Sábado</strong></th>";
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
$sql = "SELECT arrachar FROM centrodb.marcacaolar";
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$dado .= str_replace(","," ",$row['arrachar'])." ";
}
$dado = explode(" ", trim($dado));
$dados1 = array();
$data_atual = null;
foreach ($dado as $key => $value) {
$data1 = date('Y-m-d', strtotime($value));
$data2 = $value;
if (strtotime($data1) == strtotime($data2)) {
$data_atual = $value;
}else{
$dados1[$data_atual][] = $value;
}
}
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
$calendar .= "<td><input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day'>$year-$month-$day <br />
<div><input type='checkbox' class='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço'>Peq. Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' /> <br /></div>
<div><input type='checkbox' class='checkbox1' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço'>Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd'/> <br /> </div></td>
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">
</td>'; #remaining "empty" days
return $calendar."</tr>\n</table>\n";
}
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
//Monta o calendário
if(isset($_POST["data"])){
?>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
<input type='button' id='elemento' value='Aplicar a Todos' />
<?php
$calendar .= "<td><input id='firstCB{$year}{$month}{$day}' type='checkbox' name='arrachar[$year, $month, $day][dia]' value='$year-$month-$day'>$year-$month-$day <br />
<div><input type='checkbox' class='checkbox' name='arrachar[$year, $month, $day][OpcaoA]' value='Peq_Almoço'>Peq. Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd]' value='$marcado_pequeno_qtd' /> <br /></div>
<div><input type='checkbox' class='checkbox1' name='arrachar[$year, $month, $day][opcaoB]' value='Almoço'>Almoço</div> <div><input ref='firstCB{$year}{$month}{$day}' min='0' oninput='this.value = Math.abs(this.value)' type='number' name='arrachar[$year, $month, $day][Qtd1]' value='$marcado_almoco_qtd'/> <br /> </div></td>
<form name="form2" id="mainForm2" method="post" enctype="multipart/form-data" action="">
<?php
list($dia, $mes, $ano) = explode('/', $_POST["data"]);
echo generate_calendar($ano,$mes,$dia);
?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } else { ?>
<form name="form3" id="mainForm3" method="post" enctype="multipart/form-data" action="">
<?php echo generate_calendar($hoje["year"], $hoje["mon"], $hoje["mday"]); ?>
<input class="botao" type="submit" value="Marcar">
</form>
<?php } ?>
Carregando
Post restaurado por user77360
Post removido por user77360
Post restaurado por user77360
Post removido por user77360
lang-js