PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/main/tools/calendar.php

https://gitlab.com/alexprowars/bitrix
PHP | 180 lines | 166 code | 14 blank | 0 comment | 41 complexity | 13d2fdb7603b9d64b35faa5969a04a36 MD5 | raw file
  1. <?
  2. define("STOP_STATISTICS", true);
  3. define("NOT_CHECK_PERMISSIONS", true);
  4. if(isset($_GET["admin_section"]) && $_GET["admin_section"] == "Y")
  5. define("ADMIN_SECTION", true);
  6. else
  7. define("BX_PUBLIC_TOOLS", true);
  8. require_once(dirname(__FILE__)."/../include/prolog_before.php");
  9. IncludeModuleLangFile(__FILE__);
  10. $sDocPath = $APPLICATION->GetCurPage();
  11. ?>
  12. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  13. <html>
  14. <head>
  15. <title><?echo GetMessage("calend_title")?></title>
  16. <meta http-equiv="Content-Type" content="text/html; charset=<?=LANG_CHARSET?>">
  17. <style type="text/css">
  18. .headtext{font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color:#1A4D80;}
  19. .headbg{background-color:#EBEBEB;}
  20. .daytext{font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color:#1F6F9A;}
  21. .holidaytext{font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color:#970000;}
  22. </style>
  23. <?
  24. $form = preg_replace("/[^a-z0-9_\\[\\]]/i", "", $_REQUEST["form"]);
  25. $name = preg_replace("/[^a-z0-9_\\[\\]]/i", "", $_REQUEST["name"]);
  26. $from = preg_replace("/[^a-z0-9_\\[\\]]/i", "", $_REQUEST["from"]);
  27. $to = preg_replace("/[^a-z0-9_\\[\\]]/i", "", $_REQUEST["to"]);
  28. ?>
  29. <script type="text/javascript">
  30. function KeyPress()
  31. {
  32. if(window.event.keyCode == 27)
  33. window.close();
  34. }
  35. function InsertDate(valDate)
  36. {
  37. window.opener.document['<?echo $form?>']['<?echo $name?>'].value = valDate;
  38. window.close();
  39. }
  40. function InsertPeriod(valDate1, valDate2)
  41. {
  42. <?if($from <> "" && $to <> ""):?>
  43. window.opener.document['<?echo $form?>']['<?echo $from?>'].value = valDate1;
  44. window.opener.document['<?echo $form?>']['<?echo $to?>'].value = valDate2;
  45. window.close();
  46. <?else:?>
  47. InsertDate(valDate1);
  48. <?endif;?>
  49. }
  50. </script>
  51. </head>
  52. <body bgcolor="#FFFFFF" text="#000000" leftmargin="8" topmargin="8" marginwidth="8" marginheight="8" link="#be6602" alink="#de8601" vlink="#6c4500" onKeyPress="KeyPress()">
  53. <?
  54. $aMonths = array(GetMessage("calend_jan"), GetMessage("calend_feb"), GetMessage("calend_mar"), GetMessage("calend_apr"), GetMessage("calend_may"), GetMessage("calend_jun"), GetMessage("calend_jul"), GetMessage("calend_aug"), GetMessage("calend_sep"), GetMessage("calend_okt"), GetMessage("calend_nov"), GetMessage("calend_des"));
  55. global $DB;
  56. $iH=intval(FmtDate($date,"H"));
  57. $iI=intval(FmtDate($date,"I"));
  58. $iS=intval(FmtDate($date,"S"));
  59. if($iH+$iI+$iS>0)
  60. $dtformat = "FULL";
  61. else
  62. $dtformat = "SHORT";
  63. $aDate = ParseDate(FmtDate($date,"D.M.Y"),"dmy");
  64. if(is_array($aDate) && $aDate[2] > 1971 && $aDate[2] < 2037) //unix 32-bit timestamp
  65. $currDate = mktime($iH, $iI, $iS, $aDate[1], $aDate[0], $aDate[2]);
  66. else
  67. $currDate = time();
  68. $y1 = intval(date("Y", $currDate));
  69. $m1 = intval(date("n", $currDate));
  70. $d1 = intval(date("j", $currDate));
  71. $aInitDate = ParseDate(FmtDate($initdate,"D.M.Y"), "dmy");
  72. if(is_array($aInitDate) && $aInitDate[2] > 1971 && $aInitDate[2] < 2037)
  73. {
  74. $initDate = mktime($iH, $iI, $iS, $aInitDate[1], $aInitDate[0], $aInitDate[2]);
  75. $init_y = intval(date("Y", $initDate));
  76. $init_m = intval(date("n", $initDate));
  77. $init_d = intval(date("j", $initDate));
  78. }
  79. else
  80. $init_y = $init_m = $init_d = 0;
  81. $today = time();
  82. $today_y = intval(date("Y", $today));
  83. $today_m = intval(date("n", $today));
  84. $today_d = intval(date("j", $today));
  85. $sParam = DeleteParam(array("date"));
  86. if($sParam <> "")
  87. $sParam = "&amp;".$sParam;
  88. ?>
  89. <table width="100%" border="0" cellspacing="1" cellpadding="2">
  90. <tr>
  91. <td class="headbg" nowrap align="center"><font class="headtext">
  92. <a class="headtext" title="<?echo GetMessage("calend_prev_mon")?>" style="text-decoration:none; color:red;" href="<?echo $sDocPath."?date=".GetTime(mktime($iH, $iI, $iS, $m1-1, 1, $y1), $dtformat).$sParam?>">&laquo;</a>
  93. <a title="<?echo GetMessage("calend_per_mon")?>" href="javascript:InsertPeriod('<?echo GetTime(mktime($iH, $iI, $iS, $m1, 1, $y1), $dtformat)?>','<?echo GetTime(mktime($iH, $iI, $iS, $m1+1, 0, $y1), $dtformat)?>')" class="headtext"><?echo $aMonths[$m1-1]?></a>
  94. <a class="headtext" title="<?echo GetMessage("calend_next_mon")?>" style="text-decoration:none; color:red;" href="<?echo $sDocPath."?date=".GetTime(mktime($iH, $iI, $iS, $m1+1, 1, $y1), $dtformat).$sParam?>">&raquo;</a>
  95. </font></td>
  96. <td align="center" class="headbg" nowrap><font class="headtext">
  97. <a class="headtext" title="<?echo GetMessage("calend_prev_year")?>" style="text-decoration:none; color:red;" href="<?echo $sDocPath."?date=".GetTime(mktime($iH, $iI, $iS, $m1, 1, $y1-1), $dtformat).$sParam?>">&laquo;</a>
  98. <a title="<?echo GetMessage("calend_per_year")?>" href="javascript:InsertPeriod('<?echo GetTime(mktime($iH, $iI, $iS, 1, 1, $y1), $dtformat)?>','<?echo GetTime(mktime($iH, $iI, $iS, 1, 0, $y1+1), $dtformat)?>')" class="headtext"><?echo $y1?></a>
  99. <a class="headtext" title="<?echo GetMessage("calend_next_year")?>" style="text-decoration:none; color:red;" href="<?echo $sDocPath."?date=".GetTime(mktime($iH, $iI, $iS, $m1, 1, $y1+1), $dtformat).$sParam?>">&raquo;</a>
  100. </font></td>
  101. <td class="headbg" align="center"><a title="<?echo GetMessage("calend_curr")?>" href="<?echo $sDocPath."?date=".GetTime($today, $dtformat).$sParam?>" class="headtext" style="text-decoration:none; color:red;">*</a></td>
  102. </tr>
  103. </table>
  104. <table width="100%" border="0" cellspacing="2" cellpadding="1">
  105. <tr align="center">
  106. <td></td>
  107. <td class="headtext"><?echo GetMessage("calend_mo")?></td>
  108. <td class="headtext"><?echo GetMessage("calend_tu")?></td>
  109. <td class="headtext"><?echo GetMessage("calend_we")?></td>
  110. <td class="headtext"><?echo GetMessage("calend_th")?></td>
  111. <td class="headtext"><?echo GetMessage("calend_fr")?></td>
  112. <td class="headtext"><?echo GetMessage("calend_sa")?></td>
  113. <td class="headtext"><?echo GetMessage("calend_su")?></td>
  114. </tr>
  115. <?
  116. $firstDate = mktime($iH, $iI, $iS, $m1, 1, $y1);
  117. $firstDay = intval(date("w", $firstDate)-1);
  118. if($firstDay == -1)
  119. $firstDay = 6;
  120. $bBreak = false;
  121. for($i=0; $i<6; $i++)
  122. {
  123. $row = $i*7;
  124. if($i > 0 && intval(date("j", mktime($iH, $iI, $iS, $m1, 1-$firstDay+$row, $y1))) == 1)
  125. break;
  126. echo "<tr align=\"center\">\n".
  127. "<td><a title=\"".GetMessage("calend_per_week")."\" href=\"javascript:InsertPeriod('".GetTime(mktime($iH, $iI, $iS, $m1, 1-$firstDay+$row, $y1), $dtformat)."','".GetTime(mktime($iH, $iI, $iS, $m1, 1-$firstDay+$row+6, $y1), $dtformat)."')\" class=\"headtext\" style=\"text-decoration:none\">&gt;&nbsp;</a></td>";
  128. for($j=0; $j<7; $j++)
  129. {
  130. $date = mktime($iH, $iI, $iS, $m1, 1-$firstDay+$row+$j, $y1);
  131. $y = intval(date("Y", $date));
  132. $m = intval(date("n", $date));
  133. $d = intval(date("j", $date));
  134. if($i > 0 && $d == 1)
  135. $bBreak = true;
  136. $sStyle = "";
  137. if($row+$j+1 > $firstDay && !$bBreak)
  138. {
  139. if($d == $today_d && $m == $today_m && $y == $today_y)
  140. $sStyle .= "background-color:#EBEBEB; ";
  141. if($d == $init_d && $m == $init_m && $y == $init_y)
  142. $sStyle .= "border:1px solid #1E5995; ";
  143. }
  144. echo "<td style=\"".$sStyle."\">";
  145. if($row+$j+1 > $firstDay && !$bBreak)
  146. {
  147. echo
  148. "<font class=\"".($j==5 || $j==6? "holidaytext":"daytext")."\">".
  149. "<a title=\"".GetMessage("calend_date")."\" class=\"".($j==5 || $j==6? "holidaytext":"daytext")."\" href=\"javascript:InsertDate('".GetTime($date, $dtformat)."')\">".$d."</a>".
  150. "</font>";
  151. }
  152. else
  153. echo "<font class=\"daytext\">&nbsp;</font>";
  154. echo "</td>";
  155. }
  156. echo "</tr>";
  157. if($bBreak)
  158. break;
  159. }
  160. ?>
  161. </table>
  162. </body>
  163. </html>
  164. <?
  165. require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_after.php");
  166. ?>