Exemplo n.º 1
0
 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();
 }