Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- table {
- width: 100%;
- margin-bottom: 1rem;
- border-radius: 0;
- border-collapse: separate;
- }
- table tbody {
- border: 1px solid #f1f1f1;
- background-color: #fefefe;
- }
- table tbody td {
- padding: .5rem .625rem .625rem;
- }
- table tbody tr:nth-child(even) {
- background-color: #f1f1f1;
- }
- table tr td {
- height: 100px;
- }
- #calendar {
- max-width: 600px;
- text-align: center;
- margin: auto;
- }
- #calendar .days td, #calendar .title td {
- max-width: 2em;
- min-width: 2em;
- text-align: center;
- font-size: 13px;
- }
- #calendar h4 {
- font-size: 13px;
- }
- #calendar h6 {
- font-size: 12px;
- }
- #calendar .title td {
- border: 1px solid #5e5e5e;
- height: 1.2em;
- font-weight: 500;
- background: #5e5e5e;
- color: #fff;
- }
- #calendar .days td {
- height: 80px;
- background: #fff;
- vertical-align: middle;
- }
- #calendar .today {
- background: #000!important;
- color: #fff!important;
- }
- #calendar .days h6 {
- margin-bottom: .1rem!important;
- color: #b7b7b7;
- padding-top: 3px;
- }
- #calendar .days td:hover {
- background: #fbfbfb;
- }
- #calendar .days td.noel:hover {
- background: #fff;
- }
- #calendar .event, #calendar .eventtoday {
- background: #fff;
- color: #fff;
- padding: 0;
- cursor: default;
- border: 2px solid #565656!important;
- border-bottom: 1px solid #565656!important;
- }
- #calendar .eventtoday {
- background: #000!important;
- }
- #calendar .event div, #calendar .eventtoday div {
- display: block;
- vertical-align: middle;
- text-align: center;
- height: 50%;
- width: 100%;
- }
- #calendar .event div:nth-child(1), #calendar .eventtoday div:nth-child(1) {
- background: #fff;
- color: #5e5e5e;
- height: 40%;
- }
- #calendar .eventtoday div:nth-child(1) {
- background: #000!important;
- color: #fff!important;
- }
- #calendar .event h4, #calendar .eventtoday h4 {
- background: #f55!important;
- font-size: 13px;
- }
- #calendar .event div:nth-child(2), #calendar .eventtoday div:nth-child(2) {
- background: #565656;
- height: 50%;
- }
- #calendar .eventtoday div:nth-child(2) {
- background: #212121;
- }
- #calendar .event p, #calendar .eventtoday p {
- font-weight: 700;
- text-align: center;
- width: 100%;
- line-height: 15px;
- overflow: hidden;
- margin: 0;
- padding: 0;
- font-size: 11px;
- padding-top: 15px;
- }
- @media (max-width: 768px) {
- #calendar {
- width: 100%;
- }
- #calendar .title td {
- height: 1em!important;
- }
- #calendar .days td {
- height: 90px;
- }
- #calendar .event p, #calendar .eventtoday p {
- font-size: 10px!important;
- line-height: 12px;
- padding-top: 10px;
- }
- #calendar .event h4, #calendar .event h4 {
- font-size: 12px;
- }
- #calendar h4 {
- font-size: 11px;
- }
- #calendar h6 {
- font-size: 10px;
- }
- }
- </style>
- <div id="calendar-slider" class="large-12 column">
- <?php
- function Hijri($GetDate) {
- $TDays = round(strtotime($GetDate) / (60 * 60 * 24));
- $HYear = round($TDays / 354.37419);
- $Remain = $TDays - ($HYear * 354.37419);
- $HMonths = round($Remain / 29.531182);
- $HDays = $Remain - ($HMonths * 29.531182);
- $HYear = $HYear + 1389;
- $HMonths = $HMonths + 10;
- $HDays = $HDays + 23;
- if ($HDays > 29.531188 and round($HDays) != 30) {
- $HMonths = $HMonths + 1;
- $HDays = Round($HDays - 29.531182);
- } else {
- $HDays = Round($HDays);
- }
- if ($HMonths > 12) {
- $HMonths = $HMonths - 12;
- $HYear = $HYear + 1;
- }
- return array(
- $HDays,
- $HMonths,
- $HYear
- );
- }
- // -----------------------------------------------------------------//
- // --------- JADI INI YANG NANTI BUAT NYOCOKIN JADWAL --------------//
- /*
- $event = array(
- "15 Shawwal",
- "10 Zul Hijja"
- );
- $caption = array(
- "Hari Raya Idul Fitri",
- "Hari Raya Idul Adha"
- );
- */
- $arrHEvents = array( // format: "mdd" => "Events"
- '101' => "NewYear",
- '110' => "Asyura",
- '312' => "Maulid",
- '727' => "Isra",
- '917' => "Nuzulul",
- '1001' => "Fitri",
- '1210' => "Adha"
- );
- // ------------------------ CEK BAWAH -------------------------------//
- // -----------------------------------------------------------------//
- $monthnames = array(
- "Januari",
- "Februari",
- "Maret",
- "April",
- "Mei",
- "Juni",
- "Juli",
- "Augustus",
- "September",
- "Oktober",
- "November",
- "Desember"
- );
- $mname = array( // bulan
- "Muharram", // 1
- "Safar", // 2
- "Rabi'ul Awal", // 3
- "Rabi'ul Akhir",// 4
- "Jamadil Awal", // 5
- "Jamadil Akhir",// 6
- "Rajab", // 7
- "Sha'ban", // 8
- "Ramadhan", // 9
- "Shawwal", // 10
- "Zul Qida", // 11
- "Zul Hijja" // 12
- );
- /*
- $month = (isset($month)) ? $month : date("n", time());
- $textmonth = $monthnames[$month - 1];
- $year = (isset($year)) ? $year : date("Y", time());
- $today = (isset($today)) ? $today : date("j", time());
- $today = ($month == date("n", time())) ? $today : 32 - 1; // ?????
- */
- // UNTUK TEST ###############################
- $month = 4;
- $textmonth = $monthnames[$month - 1];
- $year = 2017;
- $today = 16;
- if ((($month < 8) && ($month % 2 == 1)) || (($month > 7) && ($month % 2 == 0))) {
- $days = 31;
- }
- if ((($month < 8) && ($month % 2 == 0)) || (($month > 7) && ($month % 2 == 1))) {
- $days = 30;
- }
- if ($month == 2) {
- $days = (date("L", time())) ? 29 : 28;
- }
- $dayone = date("w", mktime(1, 1, 1, $month, 1, $year)) - 1;
- $daylast = date("w", mktime(1, 1, 1, $month, $days, $year));
- $middleday = intval(($days - 1) / 2);
- $date_hijri = date("$year-$month-1");
- list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
- $smon_hijridone = $mname[$HMonths - 1];
- $syear_hijridone = $HYear;
- $date_hijri = date("$year-$month-$days");
- list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
- $smon_hijridlast = $mname[$HMonths - 1];
- $syear_hijridlast = $HYear;
- $date_hijri = date("$year-$month-$middleday");
- list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
- $smon_hijridmiddle = $mname[$HMonths - 1];
- $syear_hijridmiddle = $HYear;
- if ($syear_hijridone == $syear_hijridlast) {
- $syear_hijridone = "";
- }
- if (($smon_hijridone == $smon_hijridmiddle) AND ($smon_hijridmiddle == $smon_hijridlast)) {
- $smon_hijri = $smon_hijridone . " " . $syear_hijridlast;
- }
- if (($smon_hijridone == $smon_hijridmiddle) AND ($smon_hijridmiddle != $smon_hijridlast)) {
- $smon_hijri = $smon_hijridone . "" . $syear_hijridone . " - " . $smon_hijridlast . " " . $syear_hijridlast;
- }
- if (($smon_hijridone != $smon_hijridmiddle) AND ($smon_hijridmiddle == $smon_hijridlast)) {
- $smon_hijri = $smon_hijridone . "" . $syear_hijridone . " - " . $smon_hijridlast . " " . $syear_hijridlast;
- }
- if (($smon_hijridone != $smon_hijridmiddle) AND ($smon_hijridmiddle != $smon_hijridlast)) {
- $smon_hijri = $smon_hijridone . " " . $syear_hijridone . " - " . " - " . $smon_hijridmiddle . " - " . $smon_hijridlast . " " . $syear_hijridlast;
- }
- ?>
- <div id="calendar" align="center">
- <div class="row">
- <table>
- <tr class="title">
- <td>Sen</td>
- <td>Sel</td>
- <td>Rab</td>
- <td>Kam</td>
- <td>Jum</td>
- <td>Sab</td>
- <td>Min</td>
- </tr>
- <?php
- if ($dayone != 0) {
- $span1 = $dayone;
- }
- if (6 - $daylast != 0) {
- $span2 = 6 - $daylast;
- }
- for ($i = 1; $i <= $days; $i++) {
- $dayofweek = date("w", mktime(1, 1, 1, $month, $i, $year)) - 1;
- $b = $i < 10 ? "0$i" : $i;
- $c = $month < 10 ? "0$month" : $month;
- $date_hijri = date("$year-$month-$i");
- list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
- if ($HDays == 30) {
- $i = $i + 1;
- $date_hijri = date("$year-$month-$i");
- list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
- if ($HDays == 2) {
- $HDays = 1;
- } else {
- $HDays = 30;
- }
- $i = $i - 1;
- }
- // ##########################################################################
- $d_key = sprintf("%d%02d", $HMonths, $HDays);
- $HEvent = array_key_exists( $d_key, $arrHEvents) ? $arrHEvents[$d_key]:false;
- // ##########################################################################
- $data = $year . "-" . $c . "-" . $b;
- if ($i == 1 || $dayofweek == 0) {
- echo " <tr class=\"days\">";
- if ($span1 > 0 && $i == 1) {
- echo "<td class=\"noel\" colspan=\"$span1\"></td>";
- }
- };
- /*
- // -----------------------------------------------------------------//
- // NAH KALO MISALNYA $HDAYS . $smon_hijridone == $event[0]
- // dan $HDAYS . $smon_hijridone == $event[1]
- // Itu gimana ya?
- // -----------------------------------------------------------------//
- if ($HDAYS . $smon_hijridone == $event[0] ) {
- echo "test";
- } else {
- echo "no event";
- }
- if ($HDAYS . $smon_hijridone == $event[1] ) {
- echo "test";
- } else {
- echo "no event";
- }
- // -----------------------------------------------------------------//
- // -----------------------------------------------------------------// */
- if($i == $today) {
- if ($HDays == 1) {
- echo "<td class=\"eventtoday\">";
- } else {
- if($HEvent) {
- echo "<td class=\"eventtoday\">";
- } else {
- echo "<td class=\"today\">";
- }
- }
- };
- /*
- // -----------------------------------------------------------------//
- // NAH KALO MISALNYA $HDAYS . $smon_hijridone == $event[0]
- // dan $HDAYS . $smon_hijridone == $event[1]
- // Itu gimana ya?
- // -----------------------------------------------------------------//
- if ($HDAYS . $smon_hijridone == $event[0] ) {
- echo "test";
- } else {
- echo "no event";
- }
- if ($HDAYS . $smon_hijridone == $event[1] ) {
- echo "test";
- } else {
- echo "no event";
- }
- // -----------------------------------------------------------------//
- // -----------------------------------------------------------------//
- */
- if ($i != $today) {
- if ($HDays == 1) {
- echo "<td class=\"event\">";
- } else {
- if($HEvent) {
- echo "<td class=\"event\">";
- } else {
- echo "<td>";
- }
- }
- };
- if ($HDays == 1) {
- //$sday_hijri = "<div><h4>" . $i . "</h4></div><div><p>" . $HDays . " " . $smon_hijridlast. "</p></div>";
- $sday_hijri = "<div><h4>" . $i . "</h4></div>";
- if($HEvent)
- $sday_hijri .= "<div><p>". $HEvent ."</p></div>";
- else
- $sday_hijri .= "<div><p>" . $HDays . " " . $smon_hijridlast. "</p></div>";
- echo $sday_hijri;
- } else {
- if($HEvent)
- $sday_hijri = "<h4>" . $i . "</h4><h6>" . $HEvent . "</h6>";
- else
- $sday_hijri = "<h4>" . $i . "</h4><h6>" . $HDays . "</h6>";
- echo $sday_hijri;
- }
- echo "</td>";
- if ($i == $days) {
- if ($span2 > 0) {
- echo " <td class=\"noel\" colspan=\"$span2\"></td>";
- }
- };
- if ($dayofweek == 6 || $i == $days) {
- echo " </tr>";
- };
- };
- echo "
- </table>
- </div>
- </div>
- </div>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment