Highway to PSR2
[openemr.git] / interface / main / calendar / modules / PostCalendar / pntemplates / default / views / monthSelector.php
blob19b53a1fdc444911588cc3bd2d7bcd250263e315
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 IntegralEMR LLC <kevin.y@integralemr.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Kevin Yeh <kevin.y@integralemr.com>
25 // +------------------------------------------------------------------------------+
27 $DOMClass="DOMDocument";
28 if (!class_exists($DOMClass)) {
29 error_log("Creation of month drop down failed:".PHP_EOL."Do you have php-xml installed?");
30 return;
33 $DOM=new $DOMClass;
35 $divMonths= $DOM->createElement("DIV");
36 $divMonths->setAttribute("ID", "monthPicker");
37 $divMonths->setAttribute("style", "display:none;position: absolute; top: 15px;");
38 $DOM->appendChild($divMonths);
39 $tblMonths=$DOM->createElement("TABLE");
40 $divMonths->appendChild($tblMonths);
41 $tbodyMonths=$DOM->createElement("TBODY");
42 $tblMonths->appendChild($tbodyMonths);
43 $pMonth = date("m");
44 $pYear = date("Y");
46 $tdClasses = "tdDatePicker tdMonthName-small";
47 for ($idx=0; $idx<13; $idx++) {
48 $pDay = $cDay;
50 if ($pMonth > 12) {
51 $pMonth = $pMonth-12;
52 $pYear = $pYear + 1;
55 while (! checkdate($pMonth, $pDay, $pYear)) {
56 $pDay = $pDay - 1;
59 $pDate = sprintf("%d%02d%02d", $pYear, $pMonth, $pDay);
60 $trMonth=$DOM->createElement("TR");
61 $tdMonth=$DOM->createElement("TD", xl(date("F", strtotime($pDate)))." ".$pYear);
62 $tdMonth->setAttribute("ID", $pDate);
63 $tdMonth->setAttribute("CLASS", $tdClasses);
64 $trMonth->appendChild($tdMonth);
65 $tbodyMonths->appendChild($trMonth);
66 $pMonth = $pMonth + 1;
69 echo $DOM->saveXML($divMonths);