justhrun

Hijri Events

Jul 8th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.98 KB | None | 0 0
  1. <style>
  2. table {
  3. width: 100%;
  4. margin-bottom: 1rem;
  5. border-radius: 0;
  6. border-collapse: separate;
  7. }
  8. table tbody {
  9. border: 1px solid #f1f1f1;
  10. background-color: #fefefe;
  11. }
  12. table tbody td {
  13. padding: .5rem .625rem .625rem;
  14. }
  15. table tbody tr:nth-child(even) {
  16. background-color: #f1f1f1;
  17. }
  18. table tr td {
  19. height: 100px;
  20. }
  21. #calendar {
  22. max-width: 600px;
  23. text-align: center;
  24. margin: auto;
  25. }
  26. #calendar .days td, #calendar .title td {
  27. max-width: 2em;
  28. min-width: 2em;
  29. text-align: center;
  30. font-size: 13px;
  31. }
  32. #calendar h4 {
  33. font-size: 13px;
  34. }
  35. #calendar h6 {
  36. font-size: 12px;
  37. }
  38. #calendar .title td {
  39. border: 1px solid #5e5e5e;
  40. height: 1.2em;
  41. font-weight: 500;
  42. background: #5e5e5e;
  43. color: #fff;
  44. }
  45. #calendar .days td {
  46. height: 80px;
  47. background: #fff;
  48. vertical-align: middle;
  49. }
  50. #calendar .today {
  51. background: #000!important;
  52. color: #fff!important;
  53. }
  54. #calendar .days h6 {
  55. margin-bottom: .1rem!important;
  56. color: #b7b7b7;
  57. padding-top: 3px;
  58. }
  59. #calendar .days td:hover {
  60. background: #fbfbfb;
  61. }
  62. #calendar .days td.noel:hover {
  63. background: #fff;
  64. }
  65. #calendar .event, #calendar .eventtoday {
  66. background: #fff;
  67. color: #fff;
  68. padding: 0;
  69. cursor: default;
  70. border: 2px solid #565656!important;
  71. border-bottom: 1px solid #565656!important;
  72. }
  73. #calendar .eventtoday {
  74. background: #000!important;
  75. }
  76. #calendar .event div, #calendar .eventtoday div {
  77. display: block;
  78. vertical-align: middle;
  79. text-align: center;
  80. height: 50%;
  81. width: 100%;
  82. }
  83. #calendar .event div:nth-child(1), #calendar .eventtoday div:nth-child(1) {
  84. background: #fff;
  85. color: #5e5e5e;
  86. height: 40%;
  87. }
  88. #calendar .eventtoday div:nth-child(1) {
  89. background: #000!important;
  90. color: #fff!important;
  91. }
  92. #calendar .event h4, #calendar .eventtoday h4 {
  93. background: #f55!important;
  94. font-size: 13px;
  95. }
  96. #calendar .event div:nth-child(2), #calendar .eventtoday div:nth-child(2) {
  97. background: #565656;
  98. height: 50%;
  99. }
  100. #calendar .eventtoday div:nth-child(2) {
  101. background: #212121;
  102. }
  103. #calendar .event p, #calendar .eventtoday p {
  104. font-weight: 700;
  105. text-align: center;
  106. width: 100%;
  107. line-height: 15px;
  108. overflow: hidden;
  109. margin: 0;
  110. padding: 0;
  111. font-size: 11px;
  112. padding-top: 15px;
  113. }
  114. @media (max-width: 768px) {
  115. #calendar {
  116. width: 100%;
  117. }
  118. #calendar .title td {
  119. height: 1em!important;
  120. }
  121. #calendar .days td {
  122. height: 90px;
  123. }
  124. #calendar .event p, #calendar .eventtoday p {
  125. font-size: 10px!important;
  126. line-height: 12px;
  127. padding-top: 10px;
  128. }
  129. #calendar .event h4, #calendar .event h4 {
  130. font-size: 12px;
  131. }
  132. #calendar h4 {
  133. font-size: 11px;
  134. }
  135. #calendar h6 {
  136. font-size: 10px;
  137. }
  138.  
  139. }
  140. </style>
  141. <div id="calendar-slider" class="large-12 column">
  142. <?php
  143. function Hijri($GetDate) {
  144. $TDays = round(strtotime($GetDate) / (60 * 60 * 24));
  145. $HYear = round($TDays / 354.37419);
  146. $Remain = $TDays - ($HYear * 354.37419);
  147. $HMonths = round($Remain / 29.531182);
  148. $HDays = $Remain - ($HMonths * 29.531182);
  149. $HYear = $HYear + 1389;
  150. $HMonths = $HMonths + 10;
  151. $HDays = $HDays + 23;
  152.  
  153. if ($HDays > 29.531188 and round($HDays) != 30) {
  154. $HMonths = $HMonths + 1;
  155. $HDays = Round($HDays - 29.531182);
  156. } else {
  157. $HDays = Round($HDays);
  158. }
  159.  
  160. if ($HMonths > 12) {
  161. $HMonths = $HMonths - 12;
  162. $HYear = $HYear + 1;
  163. }
  164.  
  165. return array(
  166. $HDays,
  167. $HMonths,
  168. $HYear
  169. );
  170.  
  171. }
  172.  
  173. // -----------------------------------------------------------------//
  174. // --------- JADI INI YANG NANTI BUAT NYOCOKIN JADWAL --------------//
  175. /*
  176. $event = array(
  177. "15 Shawwal",
  178. "10 Zul Hijja"
  179. );
  180. $caption = array(
  181. "Hari Raya Idul Fitri",
  182. "Hari Raya Idul Adha"
  183. );
  184. */
  185. $arrHEvents = array( // format: "mdd" => "Events"
  186. '101' => "NewYear",
  187. '110' => "Asyura",
  188. '312' => "Maulid",
  189. '727' => "Isra",
  190. '917' => "Nuzulul",
  191. '1001' => "Fitri",
  192. '1210' => "Adha"
  193. );
  194. // ------------------------ CEK BAWAH -------------------------------//
  195. // -----------------------------------------------------------------//
  196. $monthnames = array(
  197. "Januari",
  198. "Februari",
  199. "Maret",
  200. "April",
  201. "Mei",
  202. "Juni",
  203. "Juli",
  204. "Augustus",
  205. "September",
  206. "Oktober",
  207. "November",
  208. "Desember"
  209. );
  210. $mname = array( // bulan
  211. "Muharram", // 1
  212. "Safar", // 2
  213. "Rabi'ul Awal", // 3
  214. "Rabi'ul Akhir",// 4
  215. "Jamadil Awal", // 5
  216. "Jamadil Akhir",// 6
  217. "Rajab", // 7
  218. "Sha'ban", // 8
  219. "Ramadhan", // 9
  220. "Shawwal", // 10
  221. "Zul Qida", // 11
  222. "Zul Hijja" // 12
  223. );
  224. /*
  225. $month = (isset($month)) ? $month : date("n", time());
  226. $textmonth = $monthnames[$month - 1];
  227. $year = (isset($year)) ? $year : date("Y", time());
  228. $today = (isset($today)) ? $today : date("j", time());
  229. $today = ($month == date("n", time())) ? $today : 32 - 1; // ?????
  230. */
  231.  
  232. // UNTUK TEST ###############################
  233. $month = 4;
  234. $textmonth = $monthnames[$month - 1];
  235. $year = 2017;
  236. $today = 16;
  237.  
  238. if ((($month < 8) && ($month % 2 == 1)) || (($month > 7) && ($month % 2 == 0))) {
  239. $days = 31;
  240. }
  241. if ((($month < 8) && ($month % 2 == 0)) || (($month > 7) && ($month % 2 == 1))) {
  242. $days = 30;
  243. }
  244. if ($month == 2) {
  245. $days = (date("L", time())) ? 29 : 28;
  246. }
  247.  
  248. $dayone = date("w", mktime(1, 1, 1, $month, 1, $year)) - 1;
  249. $daylast = date("w", mktime(1, 1, 1, $month, $days, $year));
  250. $middleday = intval(($days - 1) / 2);
  251.  
  252. $date_hijri = date("$year-$month-1");
  253. list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
  254. $smon_hijridone = $mname[$HMonths - 1];
  255. $syear_hijridone = $HYear;
  256.  
  257. $date_hijri = date("$year-$month-$days");
  258. list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
  259. $smon_hijridlast = $mname[$HMonths - 1];
  260. $syear_hijridlast = $HYear;
  261.  
  262. $date_hijri = date("$year-$month-$middleday");
  263. list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
  264. $smon_hijridmiddle = $mname[$HMonths - 1];
  265. $syear_hijridmiddle = $HYear;
  266.  
  267. if ($syear_hijridone == $syear_hijridlast) {
  268. $syear_hijridone = "";
  269. }
  270.  
  271. if (($smon_hijridone == $smon_hijridmiddle) AND ($smon_hijridmiddle == $smon_hijridlast)) {
  272. $smon_hijri = $smon_hijridone . " " . $syear_hijridlast;
  273. }
  274.  
  275. if (($smon_hijridone == $smon_hijridmiddle) AND ($smon_hijridmiddle != $smon_hijridlast)) {
  276. $smon_hijri = $smon_hijridone . "" . $syear_hijridone . " - " . $smon_hijridlast . " " . $syear_hijridlast;
  277. }
  278. if (($smon_hijridone != $smon_hijridmiddle) AND ($smon_hijridmiddle == $smon_hijridlast)) {
  279. $smon_hijri = $smon_hijridone . "" . $syear_hijridone . " - " . $smon_hijridlast . " " . $syear_hijridlast;
  280. }
  281.  
  282. if (($smon_hijridone != $smon_hijridmiddle) AND ($smon_hijridmiddle != $smon_hijridlast)) {
  283. $smon_hijri = $smon_hijridone . " " . $syear_hijridone . " - " . " - " . $smon_hijridmiddle . " - " . $smon_hijridlast . " " . $syear_hijridlast;
  284. }
  285.  
  286. ?>
  287.  
  288. <div id="calendar" align="center">
  289. <div class="row">
  290. <table>
  291. <tr class="title">
  292. <td>Sen</td>
  293. <td>Sel</td>
  294. <td>Rab</td>
  295. <td>Kam</td>
  296. <td>Jum</td>
  297. <td>Sab</td>
  298. <td>Min</td>
  299. </tr>
  300. <?php
  301.  
  302. if ($dayone != 0) {
  303. $span1 = $dayone;
  304. }
  305. if (6 - $daylast != 0) {
  306. $span2 = 6 - $daylast;
  307. }
  308. for ($i = 1; $i <= $days; $i++) {
  309. $dayofweek = date("w", mktime(1, 1, 1, $month, $i, $year)) - 1;
  310.  
  311.  
  312. $b = $i < 10 ? "0$i" : $i;
  313.  
  314. $c = $month < 10 ? "0$month" : $month;
  315.  
  316. $date_hijri = date("$year-$month-$i");
  317. list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
  318. if ($HDays == 30) {
  319. $i = $i + 1;
  320. $date_hijri = date("$year-$month-$i");
  321. list($HDays, $HMonths, $HYear) = Hijri($date_hijri);
  322. if ($HDays == 2) {
  323. $HDays = 1;
  324. } else {
  325. $HDays = 30;
  326. }
  327. $i = $i - 1;
  328. }
  329.  
  330.  
  331. // ##########################################################################
  332. $d_key = sprintf("%d%02d", $HMonths, $HDays);
  333. $HEvent = array_key_exists( $d_key, $arrHEvents) ? $arrHEvents[$d_key]:false;
  334. // ##########################################################################
  335.  
  336. $data = $year . "-" . $c . "-" . $b;
  337.  
  338. if ($i == 1 || $dayofweek == 0) {
  339. echo " <tr class=\"days\">";
  340. if ($span1 > 0 && $i == 1) {
  341. echo "<td class=\"noel\" colspan=\"$span1\"></td>";
  342. }
  343. };
  344.  
  345. /*
  346. // -----------------------------------------------------------------//
  347. // NAH KALO MISALNYA $HDAYS . $smon_hijridone == $event[0]
  348. // dan $HDAYS . $smon_hijridone == $event[1]
  349. // Itu gimana ya?
  350. // -----------------------------------------------------------------//
  351. if ($HDAYS . $smon_hijridone == $event[0] ) {
  352. echo "test";
  353. } else {
  354. echo "no event";
  355. }
  356.  
  357. if ($HDAYS . $smon_hijridone == $event[1] ) {
  358. echo "test";
  359. } else {
  360. echo "no event";
  361. }
  362. // -----------------------------------------------------------------//
  363. // -----------------------------------------------------------------// */
  364. if($i == $today) {
  365. if ($HDays == 1) {
  366. echo "<td class=\"eventtoday\">";
  367. } else {
  368. if($HEvent) {
  369. echo "<td class=\"eventtoday\">";
  370. } else {
  371. echo "<td class=\"today\">";
  372. }
  373. }
  374. };
  375.  
  376. /*
  377. // -----------------------------------------------------------------//
  378. // NAH KALO MISALNYA $HDAYS . $smon_hijridone == $event[0]
  379. // dan $HDAYS . $smon_hijridone == $event[1]
  380. // Itu gimana ya?
  381. // -----------------------------------------------------------------//
  382. if ($HDAYS . $smon_hijridone == $event[0] ) {
  383. echo "test";
  384. } else {
  385. echo "no event";
  386. }
  387.  
  388. if ($HDAYS . $smon_hijridone == $event[1] ) {
  389. echo "test";
  390. } else {
  391. echo "no event";
  392. }
  393. // -----------------------------------------------------------------//
  394. // -----------------------------------------------------------------//
  395. */
  396. if ($i != $today) {
  397. if ($HDays == 1) {
  398. echo "<td class=\"event\">";
  399. } else {
  400. if($HEvent) {
  401. echo "<td class=\"event\">";
  402. } else {
  403. echo "<td>";
  404. }
  405. }
  406. };
  407.  
  408. if ($HDays == 1) {
  409. //$sday_hijri = "<div><h4>" . $i . "</h4></div><div><p>" . $HDays . "&nbsp" . $smon_hijridlast. "</p></div>";
  410. $sday_hijri = "<div><h4>" . $i . "</h4></div>";
  411. if($HEvent)
  412. $sday_hijri .= "<div><p>". $HEvent ."</p></div>";
  413. else
  414. $sday_hijri .= "<div><p>" . $HDays . "&nbsp" . $smon_hijridlast. "</p></div>";
  415. echo $sday_hijri;
  416. } else {
  417. if($HEvent)
  418. $sday_hijri = "<h4>" . $i . "</h4><h6>" . $HEvent . "</h6>";
  419. else
  420. $sday_hijri = "<h4>" . $i . "</h4><h6>" . $HDays . "</h6>";
  421. echo $sday_hijri;
  422. }
  423.  
  424. echo "</td>";
  425.  
  426. if ($i == $days) {
  427. if ($span2 > 0) {
  428. echo " <td class=\"noel\" colspan=\"$span2\"></td>";
  429. }
  430. };
  431. if ($dayofweek == 6 || $i == $days) {
  432. echo " </tr>";
  433. };
  434.  
  435. };
  436.  
  437.  
  438. echo "
  439. </table>
  440. </div>
  441. </div>
  442. </div>";
  443. ?>
Advertisement
Add Comment
Please, Sign In to add comment