public function pdfCometObservations($result) { include_once "cometobjects.php"; include_once "observers.php"; include_once "instruments.php"; include_once "locations.php"; include_once "cometobservations.php"; include_once "icqmethod.php"; include_once "icqreferencekey.php"; include_once "setup/vars.php"; include_once "setup/databaseInfo.php"; global $instDir, $objCometObject, $loggedUser, $dateformat; $result = $this->sortResult($result); $objects = new CometObjects(); $observer = new Observers(); $instrument = new Instruments(); $observation = new CometObservations(); $location = new Locations(); $util = $this; $ICQMETHODS = new ICQMETHOD(); $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); $_GET['pdfTitle'] = "CometObservations.pdf"; // Create pdf file $pdf = new Cezpdf('a4', 'portrait'); $pdf->ezStartPageNumbers(300, 30, 10); $fontdir = $instDir . 'lib/fonts/Helvetica.afm'; $pdf->selectFont($fontdir); $pdf->ezText(utf8_decode(html_entity_decode(LangPDFTitle3)) . "\n"); while (list($key, $value) = each($result)) { $objectname = $objCometObject->getName($observation->getObjectId($value)); $pdf->ezText(utf8_decode($objectname), "14"); $observerid = $observation->getObserverId($value); if ($observer->getObserverProperty($loggedUser, 'UT')) { $date = sscanf($observation->getDate($value), "%4d%2d%2d"); $time = $observation->getTime($value); } else { $date = sscanf($observation->getLocalDate($value), "%4d%2d%2d"); $time = $observation->getLocalTime($value); } $hour = (int) ($time / 100); $minute = $time - $hour * 100; $formattedDate = date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0])); if ($minute < 10) { $minute = "0" . $minute; } $observername = LangPDFMessage13 . $observer->getObserverProperty($observerid, 'firstname') . " " . $observer->getObserverProperty($observerid, 'name') . html_entity_decode(LangPDFMessage14) . $formattedDate . " (" . $hour . ":" . $minute . ")"; $pdf->ezText(utf8_decode($observername), "12"); // Location and instrument if ($observation->getLocationId($value) != 0 && $observation->getLocationId($value) != 1 || $observation->getInstrumentId($value) != 0) { if ($observation->getLocationId($value) != 0 && $observation->getLocationId($value) != 1) { $locationname = LangPDFMessage10 . " : " . $location->getLocationPropertyFromId($observation->getLocationId($value), 'name'); $extra = ", "; } else { $locationname = ""; } if ($observation->getInstrumentId($value) != 0) { $instr = $instrument->getInstrumentPropertyFromId($observation->getInstrumentId($value), 'name'); if ($instr == "Naked eye") { $instr = InstrumentsNakedEye; } $locationname = $locationname . $extra . html_entity_decode(LangPDFMessage11) . " : " . $instr; if (strcmp($observation->getMagnification($value), "") != 0) { $locationname = $locationname . " (" . $observation->getMagnification($value) . " x)"; } } $pdf->ezText(utf8_decode($locationname), "12"); } // Methode $method = $observation->getMethode($value); if (strcmp($method, "") != 0) { $methodstr = html_entity_decode(LangViewObservationField15) . " : " . $method . " - " . $ICQMETHODS->getDescription($method); $pdf->ezText(utf8_decode($methodstr), "12"); } // Used chart $chart = $observation->getChart($value); if (strcmp($chart, "") != 0) { $chartstr = html_entity_decode(LangViewObservationField17) . " : " . $chart . " - " . $ICQREFERENCEKEYS->getDescription($chart); $pdf->ezText(utf8_decode($chartstr), "12"); } // Magnitude $magnitude = $observation->getMagnitude($value); if ($magnitude != -99.90000000000001) { $magstr = ""; if ($observation->getMagnitudeWeakerThan($value)) { $magstr = $magstr . LangNewComet3 . " "; } $magstr = $magstr . html_entity_decode(LangViewObservationField16) . " : " . sprintf("%.01f", $magnitude); if ($observation->getMagnitudeUncertain($value)) { $magstr = $magstr . " (" . LangNewComet2 . ")"; } $pdf->ezText(utf8_decode($magstr), "12"); } // Degree of condensation $dc = $observation->getDc($value); $coma = $observation->getComa($value); $dcstr = ""; $extra = ""; if (strcmp($dc, "") != 0 || $coma != -99) { if (strcmp($dc, "") != 0) { $dcstr = $dcstr . html_entity_decode(LangNewComet8) . " : " . $dc; $extra = ", "; } // Coma if ($coma != -99) { $dcstr = $dcstr . $extra . html_entity_decode(LangNewComet9) . " : " . $coma . "'"; } $pdf->ezText(utf8_decode($dcstr), "12"); } // Tail $tail = $observation->getTail($value); $pa = $observation->getPa($value); $tailstr = ""; $extra = ""; if ($tail != -99 || $pa != -99) { if ($tail != -99) { $tailstr = $tailstr . html_entity_decode(LangNewComet10) . " : " . $tail . "'"; $extra = ", "; } if ($pa != -99) { $tailstr = $tailstr . $extra . html_entity_decode(LangNewComet11) . " : " . $pa . ""; } $pdf->ezText(utf8_decode($tailstr), "12"); } // Description $description = $observation->getDescription($value); if (strcmp($description, "") != 0) { $descstr = html_entity_decode(LangPDFMessage15) . " : " . strip_tags($description); $pdf->ezText(utf8_decode($descstr), "12"); } $upload_dir = $instDir . 'comets/' . 'cometdrawings'; $dir = opendir($upload_dir); while (FALSE !== ($file = readdir($dir))) { if ("." == $file or ".." == $file) { continue; // skip current directory and directory above } if (fnmatch($value . ".gif", $file) || fnmatch($value . ".jpg", $file) || fnmatch($value . ".png", $file)) { $pdf->ezImage($upload_dir . "/" . $value . ".jpg", 0, 500, "none", "left"); } } $pdf->ezText(""); } $pdf->ezStream(); }
function view_observation() { global $instDir, $baseURL, $loggedUser, $dateformat, $objCometObservation, $objCometObject, $objInstrument, $objLocation, $objObserver, $objPresentations; $ICQMETHODS = new ICQMETHOD(); $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); if (!$_GET['observation']) { header("Location: " . $baseURL . "index.php"); } if ($objCometObservation->getObjectId($_GET['observation'])) { echo "<div id=\"main\">"; $content = ""; if ($_SESSION['observation_query']) { $arrayIndex = array_search($_GET['observation'], $_SESSION['observation_query']); $previousIndex = $arrayIndex + 1; @($previousObservation = $_SESSION['observation_query'][$previousIndex]); $nextIndex = $arrayIndex - 1; @($nextObservation = $_SESSION['observation_query'][$nextIndex]); if ($previousObservation != "") { $content .= "<a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $previousObservation . "\"><</a> "; } if ($nextObservation != "") { $content .= "<a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $nextObservation . "\">></a> "; } } echo "<h4>" . LangViewObservationTitle . " " . $content . "</h4>"; echo "<table class=\"table\">"; echo "<tr><td><strong>" . LangViewObservationField1 . "</strong></td>"; echo "<td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&object=" . urlencode($objCometObservation->getObjectId($_GET['observation'])) . "\">" . $objCometObject->getName($objCometObservation->getObjectId($_GET['observation'])) . "</a></td>"; echo "</tr>"; echo "<tr><td><strong>" . LangViewObservationField2 . "</strong></td>"; echo "<td><a href=\"" . $baseURL . "index.php?indexAction=detail_observer&user="******"\">" . $objObserver->getObserverProperty($objCometObservation->getObserverId($_GET['observation']), 'firstname') . " " . $objObserver->getObserverProperty($objCometObservation->getObserverId($_GET['observation']), 'name') . "</a></td>"; echo "</tr>"; $date = sscanf($objCometObservation->getDate($_GET['observation']), "%4d%2d%2d"); if ($objCometObservation->getTime($_GET['observation']) >= 0) { if (!$objObserver->getObserverProperty($loggedUser, 'UT')) { $date = sscanf($objCometObservation->getLocalDate($_GET['observation']), "%4d%2d%2d"); } } echo "<tr><td><strong>" . LangViewObservationField5 . "</strong></td>"; echo "<td>" . date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0])) . "</td>"; echo "</tr>"; if ($objCometObservation->getTime($_GET['observation']) >= 0) { if (!$objObserver->getObserverProperty($loggedUser, 'UT')) { $content1 = LangViewObservationField9lt; $time = $objCometObservation->getLocalTime($_GET['observation']); } else { $content1 = LangViewObservationField9; $time = $objCometObservation->getTime($_GET['observation']); } $time = sscanf(sprintf("%04d", $time), "%2d%2d"); $content2 = $time[0] . ":" . sprintf("%02d", $time[1]); } echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; if ($objCometObservation->getLocationId($_GET['observation']) != 0 && $objCometObservation->getLocationId($_GET['observation']) != 1) { $content1 = LangViewObservationField4; $content2 = "<a href=\"" . $baseURL . "index.php?indexAction=detail_location&location=" . urlencode($objCometObservation->getLocationId($_GET['observation'])) . "\">" . $objLocation->getLocationPropertyFromId($objCometObservation->getLocationId($_GET['observation']), 'name') . "</a>"; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getInstrumentId($_GET['observation']) != 0) { $content1 = LangViewObservationField3; $inst = $objInstrument->getInstrumentPropertyFromId($objCometObservation->getInstrumentId($_GET['observation']), 'name'); if ($objCometObservation->getMagnification($_GET['observation']) != 0) { $inst = $inst . " (" . $objCometObservation->getMagnification($_GET['observation']) . "x)"; } if (strcmp($objInstrument->getInstrumentPropertyFromId($objCometObservation->getInstrumentId($_GET['observation']), 'name'), "Naked eye") == 0) { $inst = InstrumentsNakedEye; } $content2 = "<a href=\"" . $baseURL . "index.php?indexAction=detail_instrument&instrument=" . urlencode($objCometObservation->getInstrumentId($_GET['observation'])) . "\">" . $inst . "</a>"; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getMethode($_GET['observation']) != "") { $content1 = LangViewObservationField15; $descr = $ICQMETHODS->getDescription($objCometObservation->getMethode($_GET['observation'])); $content2 = $objCometObservation->getMethode($_GET['observation']) . " - " . $descr; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getChart($_GET['observation']) != "") { $content1 = LangViewObservationField17; $descr = $ICQREFERENCEKEYS->getDescription($objCometObservation->getChart($_GET['observation'])); $content2 = $objCometObservation->getChart($_GET['observation']) . " - " . $descr; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getMagnitude($_GET['observation']) > -90) { $content1 = LangViewObservationField16; $content2 = ""; if ($objCometObservation->getMagnitudeWeakerThan($_GET['observation']) == "1") { $content2 .= LangNewComet3 . " "; } $content2 .= sprintf("%01.1f", $objCometObservation->getMagnitude($_GET['observation'])); if ($objCometObservation->getMagnitudeUncertain($_GET['observation']) == "1") { $content2 .= " (" . LangNewComet2 . ")"; } echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getDc($_GET['observation']) != '') { $content1 = LangViewObservationField18; $content2 = $objCometObservation->getDc($_GET['observation']); echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getComa($_GET['observation']) > -90) { $content1 = LangViewObservationField19; $content2 = $objCometObservation->getComa($_GET['observation']) . "'"; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getTail($_GET['observation']) > -90) { $content1 = LangViewObservationField20; $content2 = $objCometObservation->getTail($_GET['observation']) . "'"; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } if ($objCometObservation->getPa($_GET['observation']) > -90) { $content1 = LangViewObservationField21; $content2 = $objCometObservation->getPa($_GET['observation']) . "°"; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } $description = $objCometObservation->getDescription($_GET['observation']); if ($description != "") { $content1 = LangViewObservationField8; $content2 = "<textarea name=\"description\" class=\"description\" readonly cols=\"100\" rows=\"5\" >" . $objPresentations->br2nl($description) . "</textarea>"; echo "<tr><td><strong>" . $content1 . "</strong></td>"; echo "<td>" . $content2 . "</td>"; echo "</tr>"; } echo "</table>"; $upload_dir = 'cometdrawings'; $dir = opendir($instDir . 'comets/' . $upload_dir); while (FALSE !== ($file = readdir($dir))) { if ("." == $file or ".." == $file) { continue; // skip current directory and directory above } if (fnmatch($_GET['observation'] . "_resized.gif", $file) || fnmatch($_GET['observation'] . "_resized.jpg", $file) || fnmatch($_GET['observation'] . "_resized.png", $file)) { $content1 = $baseURL . "comets/" . $upload_dir . "/" . $_GET['observation'] . ".jpg"; $content2 = "<a href=\"" . $baseURL . "comets/" . $upload_dir . "/" . $_GET['observation'] . ".jpg\" data-lightbox=\"image-1\" data-title=\"\"><img class=\"account\" src=\"" . $baseURL . "comets/{$upload_dir}" . "/" . "{$file}\" alt=\"\"></img></a>"; echo $content2; echo "<hr />"; } } $role = $objObserver->getObserverProperty($loggedUser, 'role', 2); if ($loggedUser == $objCometObservation->getObserverId($_GET['observation']) || $role == RoleAdmin || $role == RoleCometAdmin) { echo "<p><a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_adapt_observation&observation=" . $_GET['observation'] . "\">" . LangChangeObservationTitle . "</a>"; echo " <a class=\"btn btn-danger\" href=\"" . $baseURL . "index.php?indexAction=comets_validate_delete_observation&observationid=" . $_GET['observation'] . "\">" . LangDeleteObservation . "</a></p>"; } if ($loggedUser != "") { $observerid = $objCometObservation->getObserverId($_GET['observation']); $name = $objObserver->getObserverProperty($observerid, 'firstname') . " " . $objObserver->getObserverProperty($observerid, 'name') . " "; $date = sscanf($objCometObservation->getDate($_GET['observation']), "%4d%2d%2d"); $object = $objCometObject->getName($objCometObservation->getObjectId($_GET['observation'])); $subject = LangMessageYourObservation . $object . LangMessageOn . $date[2] . "/" . $date[1] . "/" . $date[0]; echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=new_message&receiver=" . urlencode($observerid) . "&subject=" . urlencode($subject) . "\"><span class=\"glyphicon glyphicon-envelope\"></span> " . $name . LangMessageAboutObservation . "</a>"; echo "<br /><br />"; } } echo "</div>"; }
function new_observation() { global $baseURL, $loggedUser, $objInstrument, $objCometObject, $objCometObservation, $objPresentations, $objObserver, $objUtil, $objLocation; $role = $objObserver->getObserverProperty($loggedUser, 'role', 2); $adapt = false; echo "<div id=\"main\">"; echo "<form action=\"" . $baseURL . "index.php\" method=\"post\" enctype=\"multipart/form-data\"><div>"; if ($objUtil->checkGetKey('indexAction') == "comets_adapt_observation" && ($role == RoleAdmin || $role == RoleCometAdmin) && ($obsid = $objUtil->checkRequestKey('observation', 0))) { $adapt = true; echo "<input type=\"hidden\" name=\"observation\" value=\"" . $obsid . "\" />"; } echo "<input type=\"hidden\" name=\"indexAction\" value=\"" . ($adapt ? "comets_validate_change_observation" : "comets_validate_observation") . "\" />"; echo "<h4>" . LangNewObservationTitle . "</h4>"; echo "<input type=\"submit\" class=\"btn btn-success pull-right\" name=\"addobservation\" value=\"" . ($adapt ? LangChangeObservationTitle : LangViewObservationButton1) . "\" /> "; echo "<hr />"; $id = $objUtil->checkSessionKey('observedobject', $objUtil->checkGetKey('observedobject')); $content = "<select name=\"comet\" class=\"form-control\">"; $content .= "<option value=\"\"> </option>"; if ($adapt) { $objID = $objCometObservation->getObjectId($obsid); } else { $objID = $objUtil->checkSessionKey('observedobject', $objUtil->checkGetKey('observedobject', -1)); } $catalogs = $objCometObject->getSortedObjects("name"); while (list($key, $value) = each($catalogs)) { $content .= "<option value=\"" . $value[0] . "\"" . ($objID == $objCometObject->getId($value[0]) ? " selected=\"selected\" " : "") . ">" . $value[0] . "</option>"; } $content .= "</select>"; echo "<strong>" . LangQueryObjectsField1 . " *</strong><br />"; echo "<span class=\"form-inline\">" . $content . "</span><br />"; $content = "<input type=\"number\" min=\"1\" max=\"31\" required class=\"form-control\" maxlength=\"2\" size=\"3\" name=\"day\" value=\"" . ($adapt ? substr($objCometObservation->getDate($obsid), 6, 2) : $objUtil->checkSessionKey('day')) . "\" />"; $content .= " "; $content .= "<select name=\"month\" required class=\"form-control\">"; for ($i = 1; $i < 13; $i++) { $content .= "<option value=\"" . $i . "\"" . ($adapt ? substr($objCometObservation->getDate($obsid), 4, 2) == $i ? " selected=\"selected\"" : "" : ($objUtil->checkSessionKey('month') == $i ? " selected=\"selected\"" : "")) . ">" . $GLOBALS['Month' . $i] . "</option>"; } $content .= "</select>"; $content .= " "; $content .= "<input type=\"number\" min=\"1609\" required class=\"form-control\" maxlength=\"4\" size=\"5\" name=\"year\" value=\"" . ($adapt ? substr($objCometObservation->getDate($obsid), 0, 4) : $objUtil->checkSessionKey('year')) . "\" />"; echo "<strong>" . LangViewObservationField5 . " *</strong><br />"; echo "<span class=\"form-inline\">" . $content; echo " " . LangViewObservationField10 . "</span>"; if ($objObserver->getObserverProperty($loggedUser, 'UT')) { $content1 = LangViewObservationField9 . " *"; } else { $content1 = LangViewObservationField9lt . " *"; } $content2 = "<input type=\"number\" min=\"0\" max=\"23\" required class=\"form-control\" maxlength=\"2\" size=\"3\" name=\"hours\" value=\"" . ($adapt ? (int) ($objCometObservation->getTime($obsid) / 100) : "") . "\" /> " . "<input type=\"number\" min=\"0\" max=\"59\" required class=\"form-control\" maxlength=\"2\" size=\"3\" name=\"minutes\" value=\"" . ($adapt ? $objCometObservation->getTime($obsid) % 100 : "") . "\" />"; $content3 = LangViewObservationField11; echo "<br /><strong>" . $content1 . "</strong><br />"; echo "<span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span>"; $content1 = LangViewObservationField4; $content2 = "<select name=\"site\" class=\"form-control\">"; $sites = $objLocation->getSortedLocationsList("name", $loggedUser); if ($adapt) { $theLocation = $objCometObservation->getLocationId($obsid); } elseif (!($theLocation = $objUtil->checkSessionKey('location'))) { $theLocation = $objObserver->getObserverProperty($loggedUser, 'stdlocation', 0); } $content2 .= "<option value=\"\"> </option>"; for ($i = 0; $i < count($sites); $i++) { $content2 .= "<option " . ($theLocation == $sites[$i][0] ? " selected=\"selected\" " : "") . " value=\"" . $sites[$i][0] . "\" >" . $sites[$i][1] . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"" . $baseURL . "index.php?indexAction=add_site\">" . LangChangeAccountField7Expl . "</a>"; echo "<br /><strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangViewObservationField3; $content2 = "<select name=\"instrument\" class=\"form-control\">"; $instr = $objInstrument->getSortedInstrumentsList("name", $loggedUser); $content2 .= "<option value=\"\"> </option>"; while (list($key, $value) = each($instr)) { $instrumentname = $value; if ($adapt) { $theInstrument = $objCometObservation->getInstrumentId($obsid); } elseif (!($theInstrument = $objUtil->checkSessionKey('instrument'))) { $theInstrument = $objObserver->getObserverProperty($loggedUser, 'stdtelescope'); } $content2 .= "<option " . ($key == $theInstrument ? " selected=\"selected\"" : "") . " value=\"" . $key . "\">" . ($value == "Naked eye" ? InstrumentsNakedEye : $value) . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"" . $baseURL . "index.php?indexAction=add_instrument\">" . LangChangeAccountField8Expl . "</a>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; echo "<strong>" . LangNewComet4 . "</strong><br />"; echo "<input type=\"number\" min=\"0.0\" step=\"0.1\" class=\"form-control form-inline\" maxlength=\"3\" name=\"magnification\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getMagnification($obsid) : "") . "\"/><br />"; $ICQMETHODS = new ICQMETHOD(); $methods = $ICQMETHODS->getIds(); $content1 = LangNewComet5; $content2 = "<select name=\"icq_method\" class=\"form-control\">"; $content2 .= "<option value=\"\"> </option>"; while (list($key, $value) = each($methods)) { $content2 .= "<option value=\"" . $value . "\"" . ($adapt ? $objCometObservation->getMethode($obsid) == $value ? " selected=\"selected\" " : "" : "") . ">" . $value . " - " . $ICQMETHODS->getDescription($value) . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"http://cfa-www.harvard.edu/icq/ICQKeys.html\" rel=\"external\">" . LangNewComet7 . "</a>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); $methods = $ICQREFERENCEKEYS->getIds(); $content1 = LangNewComet6; $content2 = "<select name=\"icq_reference_key\" class=\"form-control\">"; $content2 .= "<option value=\"\"> </option>"; while (list($key, $value) = each($methods)) { $content2 .= "<option value=\"{$value}\"" . ($adapt ? $objCometObservation->getChart($obsid) == $value ? " selected=\"selected\" " : "" : "") . ">" . $value . " - " . $ICQREFERENCEKEYS->getDescription($value) . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"http://cfa-www.harvard.edu/icq/ICQRec.html\" rel=\"external\">" . LangNewComet7 . "</a>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangNewComet1; $content2 = "<select name=\"smaller\" class=\"form-control\">"; $content2 .= "<option value=\"0\"> </option>"; $content2 .= "<option value=\"1\"" . ($adapt && $objCometObservation->getMagnitudeWeakerThan($obsid) ? " selected=\"selected\" " : "") . ">" . LangNewComet3 . "</option>"; $content2 .= "</select>"; $content2 .= " "; $content2 .= "<input type=\"number\" min=\"-5.00\" step=\"0.01\" class=\"form-control\" maxlength=\"4\" name=\"mag\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getMagnitude($obsid) != -99.90000000000001 ? $objCometObservation->getMagnitude($obsid) : '' : "") . "\"/>"; $content2 .= " <input type=\"checkbox\" name=\"uncertain\" " . ($adapt && $objCometObservation->getMagnitudeUncertain($obsid) ? " checked=\"checked\" " : "") . " />" . LangNewComet2; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo "</span><br />"; $content1 = LangNewComet8; $content2 = "<select name=\"condensation\" class=\"form-control\">"; $content2 .= "<option value=\"\"> </option>"; for ($i = 0; $i <= 9; $i++) { $content2 .= "<option value=\"" . $i . "\"" . ($adapt && $objCometObservation->getDc($obsid) == $i ? " selected=\"selected\" " : "") . ">" . $i . "</option>"; } $content2 .= "</select>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo "</span><br />"; $content1 = LangNewComet9; $content2 = "<input type=\"number\" min=\"0.0\" step=\"0.1\" class=\"form-control\" maxlength=\"3\" name=\"coma\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getComa($obsid) != -99 ? $objCometObservation->getComa($obsid) : '' : "") . "\" />"; $content3 = LangNewComet13; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangNewComet10; $content2 = "<input type=\"number\" min=\"0.0\" step=\"0.1\" class=\"form-control\" maxlength=\"3\" name=\"tail_length\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getTail($obsid) != -99 ? $objCometObservation->getTail($obsid) : '' : "") . "\" />"; $content3 = LangNewComet13; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangNewComet11; $content2 = "<input type=\"number\" min=\"0.0\" max=\"360.0\" step=\"0.1\" class=\"form-control\" maxlength=\"3\" name=\"position_angle\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getPa($obsid) != -99 ? $objCometObservation->getPa($obsid) : '' : "") . "\" />"; $content3 = LangNewComet12; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangViewObservationField12; $content2 = "<input type=\"file\" name=\"drawing\" class=\"inputField\" />"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo "</span><br />"; $content1 = LangViewObservationField8; $content2 = "<textarea name=\"description\" class=\"form-control\" rows=\"5\" >" . ($adapt ? $objCometObservation->getDescription($obsid) : "") . "</textarea>"; echo "<strong>" . $content1 . "</strong>"; echo "<br />" . $content2; echo "<br />"; echo "</div></form>"; echo "<hr />"; echo "</div>"; }
function new_observation() { global $baseURL, $loggedUser, $objInstrument, $objCometObject, $objCometObservation, $objPresentations, $objObserver, $objUtil, $objLocation, $instDir; $role = $objObserver->getObserverProperty($loggedUser, 'role', 2); $adapt = false; echo "<div id=\"main\">"; echo "<form action=\"" . $baseURL . "index.php\" method=\"post\" enctype=\"multipart/form-data\"><div>"; $obsid = $objUtil->checkRequestKey('observation', 0); if ($objUtil->checkGetKey('indexAction') == "comets_adapt_observation" && ($role == RoleAdmin || $role == RoleCometAdmin || $loggedUser == $objCometObservation->getObserverId($obsid))) { $adapt = true; echo "<input type=\"hidden\" name=\"observation\" value=\"" . $obsid . "\" />"; } echo "<input type=\"hidden\" name=\"indexAction\" value=\"" . ($adapt ? "comets_validate_change_observation" : "comets_validate_observation") . "\" />"; echo "<h4>" . LangNewObservationTitle . "</h4>"; echo "<input type=\"submit\" class=\"btn btn-success pull-right\" name=\"addobservation\" value=\"" . ($adapt ? LangChangeObservationTitle : LangViewObservationButton1) . "\" /> "; echo "<hr />"; $id = $objUtil->checkSessionKey('observedobject', $objUtil->checkGetKey('observedobject')); $content = "<select name=\"comet\" class=\"form-control\">"; $content .= "<option value=\"\"> </option>"; if ($adapt) { $objID = $objCometObservation->getObjectId($obsid); } else { $objID = $objUtil->checkSessionKey('observedobject', $objUtil->checkGetKey('observedobject', -1)); } $catalogs = $objCometObject->getSortedObjects("name"); while (list($key, $value) = each($catalogs)) { $content .= "<option value=\"" . $value[0] . "\"" . ($objID == $objCometObject->getId($value[0]) ? " selected=\"selected\" " : "") . ">" . $value[0] . "</option>"; } $content .= "</select>"; echo "<strong>" . LangQueryObjectsField1 . " *</strong><br />"; echo "<span class=\"form-inline\">" . $content . "</span><br />"; $content = "<input type=\"number\" min=\"1\" max=\"31\" required class=\"form-control\" maxlength=\"2\" size=\"3\" name=\"day\" value=\"" . ($adapt ? substr($objCometObservation->getDate($obsid), 6, 2) : $objUtil->checkSessionKey('day')) . "\" />"; $content .= " "; $content .= "<select name=\"month\" required class=\"form-control\">"; for ($i = 1; $i < 13; $i++) { $content .= "<option value=\"" . $i . "\"" . ($adapt ? substr($objCometObservation->getDate($obsid), 4, 2) == $i ? " selected=\"selected\"" : "" : ($objUtil->checkSessionKey('month') == $i ? " selected=\"selected\"" : "")) . ">" . $GLOBALS['Month' . $i] . "</option>"; } $content .= "</select>"; $content .= " "; $content .= "<input type=\"number\" min=\"1609\" required class=\"form-control\" maxlength=\"4\" size=\"5\" name=\"year\" value=\"" . ($adapt ? substr($objCometObservation->getDate($obsid), 0, 4) : $objUtil->checkSessionKey('year')) . "\" />"; echo "<strong>" . LangViewObservationField5 . " *</strong><br />"; echo "<span class=\"form-inline\">" . $content; echo " " . LangViewObservationField10 . "</span>"; if ($objObserver->getObserverProperty($loggedUser, 'UT')) { $content1 = LangViewObservationField9 . " *"; } else { $content1 = LangViewObservationField9lt . " *"; } $content2 = "<input type=\"number\" min=\"0\" max=\"23\" required class=\"form-control\" maxlength=\"2\" size=\"3\" name=\"hours\" value=\"" . ($adapt ? (int) ($objCometObservation->getTime($obsid) / 100) : "") . "\" /> " . "<input type=\"number\" min=\"0\" max=\"59\" required class=\"form-control\" maxlength=\"2\" size=\"3\" name=\"minutes\" value=\"" . ($adapt ? $objCometObservation->getTime($obsid) % 100 : "") . "\" />"; $content3 = LangViewObservationField11; echo "<br /><strong>" . $content1 . "</strong><br />"; echo "<span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span>"; $content1 = LangViewObservationField4; $content2 = "<select name=\"site\" class=\"form-control\">"; $sites = $objLocation->getSortedLocationsList("name", $loggedUser); if ($adapt) { $theLocation = $objCometObservation->getLocationId($obsid); } elseif (!($theLocation = $objUtil->checkSessionKey('location'))) { $theLocation = $objObserver->getObserverProperty($loggedUser, 'stdlocation', 0); } $content2 .= "<option value=\"\"> </option>"; for ($i = 0; $i < count($sites); $i++) { $content2 .= "<option " . ($theLocation == $sites[$i][0] ? " selected=\"selected\" " : "") . " value=\"" . $sites[$i][0] . "\" >" . $sites[$i][1] . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"" . $baseURL . "index.php?indexAction=add_location\">" . LangChangeAccountField7Expl . "</a>"; echo "<br /><strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangViewObservationField3; $content2 = "<select name=\"instrument\" class=\"form-control\">"; $instr = $objInstrument->getSortedInstrumentsList("name", $loggedUser); $content2 .= "<option value=\"\"> </option>"; while (list($key, $value) = each($instr)) { $instrumentname = $value; if ($adapt) { $theInstrument = $objCometObservation->getInstrumentId($obsid); } elseif (!($theInstrument = $objUtil->checkSessionKey('instrument'))) { $theInstrument = $objObserver->getObserverProperty($loggedUser, 'stdtelescope'); } $content2 .= "<option " . ($key == $theInstrument ? " selected=\"selected\"" : "") . " value=\"" . $key . "\">" . ($value == "Naked eye" ? InstrumentsNakedEye : $value) . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"" . $baseURL . "index.php?indexAction=add_instrument\">" . LangChangeAccountField8Expl . "</a>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; echo "<strong>" . LangNewComet4 . "</strong><br />"; echo "<input type=\"number\" min=\"0.0\" step=\"0.1\" class=\"form-control form-inline\" maxlength=\"3\" name=\"magnification\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getMagnification($obsid) : "") . "\"/><br />"; $ICQMETHODS = new ICQMETHOD(); $methods = $ICQMETHODS->getIds(); $content1 = LangNewComet5; $content2 = "<select name=\"icq_method\" class=\"form-control\">"; $content2 .= "<option value=\"\"> </option>"; while (list($key, $value) = each($methods)) { $content2 .= "<option value=\"" . $value . "\"" . ($adapt ? $objCometObservation->getMethode($obsid) == $value ? " selected=\"selected\" " : "" : "") . ">" . $value . " - " . $ICQMETHODS->getDescription($value) . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"http://cfa-www.harvard.edu/icq/ICQKeys.html\" rel=\"external\">" . LangNewComet7 . "</a>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); $methods = $ICQREFERENCEKEYS->getIds(); $content1 = LangNewComet6; $content2 = "<select name=\"icq_reference_key\" class=\"form-control\">"; $content2 .= "<option value=\"\"> </option>"; while (list($key, $value) = each($methods)) { $content2 .= "<option value=\"{$value}\"" . ($adapt ? $objCometObservation->getChart($obsid) == $value ? " selected=\"selected\" " : "" : "") . ">" . $value . " - " . $ICQREFERENCEKEYS->getDescription($value) . "</option>"; } $content2 .= "</select>"; $content3 = "<a href=\"http://cfa-www.harvard.edu/icq/ICQRec.html\" rel=\"external\">" . LangNewComet7 . "</a>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangNewComet1; $content2 = "<select name=\"smaller\" class=\"form-control\">"; $content2 .= "<option value=\"0\"> </option>"; $content2 .= "<option value=\"1\"" . ($adapt && $objCometObservation->getMagnitudeWeakerThan($obsid) ? " selected=\"selected\" " : "") . ">" . LangNewComet3 . "</option>"; $content2 .= "</select>"; $content2 .= " "; $content2 .= "<input type=\"number\" min=\"-5.00\" step=\"0.01\" class=\"form-control\" maxlength=\"4\" name=\"mag\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getMagnitude($obsid) != -99.90000000000001 ? $objCometObservation->getMagnitude($obsid) : '' : "") . "\"/>"; $content2 .= " <input type=\"checkbox\" name=\"uncertain\" " . ($adapt && $objCometObservation->getMagnitudeUncertain($obsid) ? " checked=\"checked\" " : "") . " />" . LangNewComet2; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo "</span><br />"; $content1 = LangNewComet8; $content2 = "<select name=\"condensation\" class=\"form-control\">"; $content2 .= "<option value=\"\"> </option>"; for ($i = 0; $i <= 9; $i++) { $content2 .= "<option value=\"" . $i . "\"" . ($adapt && $objCometObservation->getDc($obsid) == $i ? " selected=\"selected\" " : "") . ">" . $i . "</option>"; } $content2 .= "</select>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo "</span><br />"; $content1 = LangNewComet9; $content2 = "<input type=\"number\" min=\"0.0\" step=\"0.1\" class=\"form-control\" maxlength=\"3\" name=\"coma\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getComa($obsid) != -99 ? $objCometObservation->getComa($obsid) : '' : "") . "\" />"; $content3 = LangNewComet13; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangNewComet10; $content2 = "<input type=\"number\" min=\"0.0\" step=\"0.1\" class=\"form-control\" maxlength=\"3\" name=\"tail_length\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getTail($obsid) != -99 ? $objCometObservation->getTail($obsid) : '' : "") . "\" />"; $content3 = LangNewComet13; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangNewComet11; $content2 = "<input type=\"number\" min=\"0.0\" max=\"360.0\" step=\"0.1\" class=\"form-control\" maxlength=\"3\" name=\"position_angle\" size=\"4\" value=\"" . ($adapt ? $objCometObservation->getPa($obsid) != -99 ? $objCometObservation->getPa($obsid) : '' : "") . "\" />"; $content3 = LangNewComet12; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form-inline\">" . $content2; echo " " . $content3 . "</span><br />"; $content1 = LangViewObservationField12; $content2 = "<input type=\"file\" id=\"drawing\" name=\"drawing\" data-show-remove=\"false\" accept=\"image/*\" class=\"file-loading\" />"; // Make sure to show the current drawing $imaLocation = ""; if ($obsid) { $upload_dir = 'cometdrawings'; $dir = opendir($instDir . 'comets/' . $upload_dir); while (FALSE !== ($file = readdir($dir))) { if ("." == $file or ".." == $file) { continue; // skip current directory and directory above } if (fnmatch($obsid . "_resized.gif", $file) || fnmatch($obsid . "_resized.jpg", $file) || fnmatch($obsid . "_resized.png", $file)) { $imaLocation = $baseURL . "comets/" . $upload_dir . "/" . $obsid . ".jpg"; } } } // The javascript for the fileinput plugins echo "<script type=\"text/javascript\">"; echo "\$(document).on(\"ready\", function() {\n\t\t\$(\"#drawing\").fileinput({"; if ($imaLocation != "") { echo " initialPreview: [\n\t\t\t\t\t// Show the correct file.\n\t\t\t\t\t'<img src=\"" . $imaLocation . "\" class=\"file-preview-image\">'\n\t\t\t\t],"; } echo "\n\t\t\tmaxFileCount: 1,\n\t\t\tvalidateInitialCount: true,\n\t\t\toverwriteInitial: true,\n\t\t\tautoReplace: true,\n\t\t\tshowRemove: false,\n\t\t\tshowUpload: false,\n\t\t\tremoveLabel: '',\n\t\t\tremoveIcon: '',\n\t\t\tremoveTitle: '',\n\t\t\tlayoutTemplates: {actionDelete: ''},\n\t\t\tallowedFileTypes: [\"image\"],\n\t\t\tinitialCaption: \"" . LangViewObservationField12 . "\",\n\t\t});\n\t});"; echo "</script>"; echo "<strong>" . $content1 . "</strong>"; echo "<br /><span class=\"form\">" . $content2; echo "</span><br />"; $content1 = LangViewObservationField8; $content2 = "<textarea name=\"description\" class=\"form-control\" rows=\"5\" >" . ($adapt ? $objCometObservation->getDescription($obsid) : "") . "</textarea>"; echo "<strong>" . $content1 . "</strong>"; echo "<br />" . $content2; echo "<br />"; echo "</div>"; echo "<input type=\"submit\" class=\"btn btn-success\" name=\"addobservation\" value=\"" . ($adapt ? LangChangeObservationTitle : LangViewObservationButton1) . "\" /> "; echo "</form>"; echo "<hr />"; echo "</div>"; }