function wkdaynum($daynum, $mon, $yr) { $jd = gregoriantojd($mon, $daynum, $yr); switch (JDDayOfWeek($jd, 0)) { case 0: return 6; case 1: return 0; case 2: return 1; case 3: return 2; case 4: return 3; case 5: return 4; case 6: return 5; } }
function weekday($daynum, $mon, $yr) { $jd = gregoriantojd($mon, $daynum, $yr); switch (JDDayOfWeek($jd, 0)) { case 0: return "<font color=red>Sonntag</font>"; case 1: return "Montag"; case 2: return "Dienstag"; case 3: return "Mittwoch"; case 4: return "Donnerstag"; case 5: return "Freitag"; case 6: return "Samstag"; } }
$conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id FROM massageAppointment WHERE date = '{$date}' AND instructor = '{$instructor}'"; $result = $conn->query($sql); $row_cnt = $result->num_rows; if ($row_cnt > 0) { $message = "This instructor is unavailable at this date and time, please try another one or get in touch with our Appointment Supervisor."; echo "<script type='text/javascript'>alert('{$message}');</script>"; } else { $day = date('d', strtotime($date)); $month = date('m', strtotime($date)); $year = date('Y', strtotime($date)); $jd = GregorianToJD($month, $day, $year); $dayOfWeek = JDDayOfWeek($jd, 0); if ($instructor === 'Marry Pendleton' && $dayOfWeek === 0) { $message = "This instructor is unavailable on Sundays, please try another day or get in touch with our Appointment Supervisor."; echo "<script type='text/javascript'>alert('{$message}');</script>"; } elseif ($instructor === 'Marry Pendleton' && $dayOfWeek === 2 || $dayOfWeek === 4) { $message = "This instructor is unavailable on Tuesdays and Thursdays, please try another day or get in touch with our Appointment Supervisor."; echo "<script type='text/javascript'>alert('{$message}');</script>"; } elseif ($instructor === 'Claudette Hester' && $dayOfWeek === 1 || $dayOfWeek === 3 || $dayOfWeek === 5) { $message = "This instructor is unavailable on Mondays, Wednesdays and Fridays, please try another day or get in touch with our Appointment Supervisor."; echo "<script type='text/javascript'>alert('{$message}');</script>"; } elseif ($instructor === 'Claudette Hester' && $dayOfWeek === 6) { $message = "This instructor is unavailable on Saturdays, please try another day or get in touch with our Appointment Supervisor."; echo "<script type='text/javascript'>alert('{$message}');</script>"; } else { $query = "\n\t\t\t\t\tINSERT INTO `group5`.`massageAppointment` (`id`, `firstName`, `lastName`, `instructor`, `date`, `email`, `massageLength`,\n\t\t\t\t\t`massageType`) VALUES (NULL, '{$fname}', '{$lname}', '{$instructor}', '{$date}', '{$email}', '{$massageLength}',\n\t\t\t\t\t'{$massageType}');"; $conn->query($query);
function show_calendar_week($id, $option, $rows, $date) { $JLMS_CONFIG =& JLMSFactory::getConfig(); $Itemid = $JLMS_CONFIG->get('Itemid'); $month = date('m', $date); $day = date('j', $date); $year = date('Y', $date); $choose_date = JLMS_dateToDisplay(date('Y-m-d', $date)); $date_format_fdow = $JLMS_CONFIG->get('date_format_fdow'); /*<script type="text/javascript" src="<?php echo $JLMS_CONFIG->get('live_site');?>/includes/js/joomla.javascript.js "></script>*/ ?> <script type="text/javascript" language="javascript"> <!-- function td_hover(elem){ getObj(elem).style['background'] = '#EEEEEE'; getObj(elem).style.color = '#000000'; //getObj(elem).style.cursor = 'pointer'; } //function out to other days function td_out(elem){ getObj(elem).style['background'] = ''; getObj(elem).style.color = ''; } //function out to weekneds days function td_out2(elem){ getObj(elem).style['background'] = '#E1CDCD'; getObj(elem).style.color = ''; } //function out to current day function td_out3(elem){ getObj(elem).style['background'] = '#FBA179'; getObj(elem).style.color = ''; } --> </script> <script language="javascript" type="text/javascript"> <!--// function quick_date(){ document.forms.jlms_agenda_form_day.submit(); } //--> </script> <form action="<?php echo sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"); ?> " method="post" name="jlms_agenda_form_day"> <table cellpadding="0" cellspacing="0" border="0" style="height:20px" class="jlms_table_no_borders"> <tr> <td valign="middle" align="center" width="18"> <?php echo JLMS_HTML::_('calendar.calendar', $choose_date, 'cal', 'jlms_choose', null, null, 'statictext'); ?> </td><td valign="middle" align="center" width="18"> <span onclick="quick_date()" style=" cursor:pointer" title="<?php echo _JLMS_AGENDA_GO_DATE; ?> "> <img src="<?php echo $JLMS_CONFIG->get('live_site'); ?> /components/com_joomla_lms/lms_images/agenda/loopnone.png" alt="<?php echo _JLMS_AGENDA_GO_DATE; ?> " title="<?php echo _JLMS_AGENDA_GO_DATE; ?> " id="go_date" border="0" width="16" height="16" class="JLMS_png" /> </span> </td> </tr> </table> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?> " /> <input type="hidden" name="task" value="agenda" /> <input type="hidden" name="mode" value="view_week" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="id" value="<?php echo $id; ?> " /> </form> <?php $wday = JDDayOfWeek(GregorianToJD($month, $day, $year), 0); if ($date_format_fdow == 1) { if ($wday == 0) { $wday = 7; } $mon_day_num = strtotime("-" . ($wday - 1) . " day", $date); $sun_day_num = strtotime("+" . (7 - $wday) . " day", $date); $num_sat = 5; $num_sun = 6; } else { $mon_day_num = strtotime("-" . $wday . " day", $date); $sun_day_num = strtotime("+" . (6 - $wday) . " day", $date); $num_sat = 0; $num_sun = 6; } ?> <!-- Shablon calendaria. --> <table cellpadding="0" cellspacing="0" width="100%"> <tr style="background: url('<?php echo $JLMS_CONFIG->get('live_site'); ?> /components/com_joomla_lms/lms_images/agenda/bg.jpg') #cccccc repeat-x; font-weight:bold; color:white;height:20px " valign="middle"> <td valign="middle" align="center"> <a class="jlms_img_link" href="<?php echo sefRelToAbs("index.php?option={$option}&Itemid=" . $Itemid . "&task=agenda&mode=view_week&id=" . $id . "&date=" . JLMS_dateToDisplay(strtotime("-1 week", $date), true)); ?> "> <img src="<?php echo $JLMS_CONFIG->get('live_site'); ?> /components/com_joomla_lms/lms_images/agenda/ag_previous.png" class="JLMS_png" alt="<?php echo _JLMS_AGENDA_PREVIOUSWEEK; ?> " title="<?php echo _JLMS_AGENDA_PREVIOUSWEEK; ?> " width="16" height="16" border="0"/> </a> </td> <td align="center" style="text-align:center" valign="middle" colspan="5"> (<?php echo day_month_lang(date('w d m Y', $mon_day_num), 0, 1, 5, 2) . " - " . day_month_lang(date('w d m Y', $sun_day_num), 0, 1, 5, 2); ?> ) </td> <td valign="middle" align="center"> <a class="jlms_img_link" href="<?php echo sefRelToAbs("index.php?option={$option}&Itemid=" . $Itemid . "&task=agenda&mode=view_week&id=" . $id . "&date=" . JLMS_dateToDisplay(strtotime("+1 week", $date), true)); ?> "> <img src="<?php echo $JLMS_CONFIG->get('live_site'); ?> /components/com_joomla_lms/lms_images/agenda/ag_next.png" class="JLMS_png" alt="<?php echo _JLMS_AGENDA_NEXTWEEK; ?> " title="<?php echo _JLMS_AGENDA_NEXTWEEK; ?> " width="16" height="16" border="0"/> </a></td> </tr> <!-- cycle of rows --> <?php echo "<tr>"; $i = 0; $br_right = ''; for ($i; $i < 7; $i++) { if ($i == 6) { $br_right = ';border-right:1px solid #B3B3B3'; } echo "<td style='width:14%;text-align:center; height:15px;background:#cccccc;border-bottom:1px solid #B3B3B3; border-left:1px solid #B3B3B3 {$br_right}' >" . month_lang(strftime('%m %Y', strtotime("+{$i} day", $mon_day_num)), 0, 2) . "<br />" . day_month_lang(date("w", strtotime("+{$i} day", $mon_day_num)), 0, 1, 0, 0) . "</td>"; } echo "</tr>"; $i = 0; echo "<tr>"; for ($i; $i < 7; $i++) { if ($i == $num_sat || $i == $num_sun) { $color = ''; if ($i == 6) { $color = "border-right:1px solid #B3B3B3; "; } $color .= "background:#E1CDCD;border-left:1px solid #B3B3B3; border-bottom:1px solid #B3B3B3; "; $w = '2'; } else { $color = 'border-bottom:1px solid #B3B3B3; border-left:1px solid #B3B3B3;'; $w = ''; } if (date("" . $year . "-" . $month . "-" . $i . "", $date) == date('Y-m-d')) { $color = "background:#FBA179;border:1px solid #B3B3B3;"; $w = '3'; } $today = ''; if (date('Y-m-d', strtotime("+{$i} day", $mon_day_num)) == date('Y-m-d')) { $color = "background:#FBA179;border-left:1px solid #B3B3B3;border-bottom:1px solid #B3B3B3;"; $w = '3'; //$today = _JLMS_AGENDA_TODAY; } //if ($i == 0){ echo "<tr>";} echo "<td style='" . $color . "width:14%; height:40px;' valign='top' id='day" . $i . "' onmouseover=\"td_hover('day" . $i . "')\" onmouseout=\"td_out" . $w . "('day" . $i . "')\">" . $today . "<br />"; $k = 0; while (isset($rows[$k]) && $k < count($rows)) { if (strtotime("+{$i} day", $mon_day_num) >= strtotime($rows[$k]->start_date) && strtotime("+{$i} day", $mon_day_num) <= strtotime($rows[$k]->end_date)) { $title = substr($rows[$k]->title, 0, 12); $title .= strlen($rows[$k]->title) > 12 ? "..." : ''; $descr = strip_tags($rows[$k]->content); $overlib_descr = substr($descr, 0, 120) . (strlen($descr) > 120 ? "..." : ''); $overlib_descr = JLMS_txt2overlib($overlib_descr); $overlib_title = JLMS_txt2overlib($rows[$k]->title); $link = sefRelToAbs("index.php?option={$option}&&Itemid={$Itemid}&task=agenda&id={$id}&agenda_id=" . $rows[$k]->agenda_id . "&date=" . date("Y-m", $date) . "#anc" . $rows[$k]->agenda_id . '-' . date("Y-m", $date) . ""); echo JLMS_toolTip($overlib_title, $overlib_descr, $title, $link); echo '<br />'; } $k++; } echo "</td>"; } echo "</tr>"; ?> </table> <?php }
public function my_makeCal($year, $month) { $day_amount = array(1 => '31', 2 => array(false => '28', true => '29'), 3 => '31', 4 => '30', 5 => '31', 6 => '30', 7 => '31', 8 => '31', 9 => '30', 10 => '31', 11 => '30', 12 => '31'); if ($month == 2) { $day_in_month = $day_amount[$month][$year % 4 == 0]; } else { $day_in_month = $day_amount[$month]; } // Получаем номер дня недели для 1 числа месяца. // Получаем номер дня недели для последнего дня месяца. // Корректируем их, чтобы воскресенье соответствовало числу 7, а не числу 0. $wday = JDDayOfWeek(GregorianToJD($month, 1, $year), 0); $wday_end_month = JDDayOfWeek(GregorianToJD($month, $day_in_month, $year), 0); if ($wday == 0) { $wday = 7; } if ($wday_end_month == 0) { $wday_end_month = 7; } //Заполняем массив календаря значениями от 1 до последнего числа месяца $cal = range(1, $day_in_month); //если первое число не совпадает с понедельником if ($wday > 1) { $cal_b = array_fill(0, $wday - 1, ''); //заполняет массив пустыми значениями $cal = array_merge($cal_b, $cal); //склеиваем массив дат и пустышку } //если последнее число не совпадает с воскресеньем if ($wday_end_month < 7) { $cal_e = array_fill(0, 7 - $wday_end_month, ''); //заполняет массив пустыми значениями $cal = array_merge($cal, $cal_e); //склеиваем массив дат и пустышку } $cal = array_chunk($cal, 7); return $cal; }