public function rssObservations() { global $objObservation, $objInstrument, $objLocation, $objPresentations, $objObserver, $baseURL, $objUtil; $dom = new DomDocument('1.0', 'US-ASCII'); // add root fcga -> The header $rssInfo = $dom->createElement('rss'); $rssDom = $dom->appendChild($rssInfo); $attr = $dom->createAttribute("version"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("2.0"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:content"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://purl.org/rss/1.0/modules/content/"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:dc"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://purl.org/dc/elements/1.1/"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:atom"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://www.w3.org/2005/Atom"); $attr->appendChild($attrText); // add root - <channel> $channelDom = $rssDom->appendChild($dom->createElement('channel')); // add root - <channel> - <title> $titleDom = $channelDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode("DeepskyLog")); // add root - <channel> - <description> $descDom = $channelDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createTextNode("DeepskyLog - visual deepsky and comets observations")); // add root - <channel> - <atom> $atomDom = $channelDom->appendChild($dom->createElement('atom:link')); $attr = $dom->createAttribute("href"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode($baseURL . "observations.rss"); $attr->appendChild($attrText); $attr = $dom->createAttribute("rel"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode("self"); $attr->appendChild($attrText); $attr = $dom->createAttribute("type"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode("application/rss+xml"); $attr->appendChild($attrText); // add root - <channel> - <link> $linkDom = $channelDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createTextNode("http://www.deepskylog.org/")); $theDate = date('r'); // add root - <channel> - <link> $lbdDom = $channelDom->appendChild($dom->createElement('lastBuildDate')); $lbdDom->appendChild($dom->createTextNode($theDate)); // Get the new deepsky observations of the last month $theDate = date('Ymd', strtotime('-1 month')); $_GET['minyear'] = substr($theDate, 0, 4); $_GET['minmonth'] = substr($theDate, 4, 2); $_GET['minday'] = substr($theDate, 6, 2); $query = array("catalog" => '%', "mindate" => $objUtil->checkGetDate('minyear', 'minmonth', 'minday')); $result = $objObservation->getObservationFromQuery($query, 'A'); while (list($key, $value) = each($result)) { // add root - <channel> - <item> $itemDom = $channelDom->appendChild($dom->createElement('item')); $titleDom = $itemDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode($value['observername'] . " : " . $value['objectname'] . " with " . htmlspecialchars_decode($objInstrument->getInstrumentPropertyFromId($value['instrumentid'], 'name')) . " from " . $objLocation->getLocationPropertyFromId($objObservation->getDsObservationProperty($value['observationid'], 'locationid'), 'name'))); $linkDom = $itemDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=detail_observation&observation=" . $value['observationid'] . "&QobsKey=0&dalm=D")); $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($value['observationdescription'])))); $authorDom = $itemDom->appendChild($dom->createElement('dc:creator')); $authorDom->appendChild($dom->createCDATASection($value['observername'])); $guidDom = $itemDom->appendChild($dom->createElement('guid')); $guidDom->appendChild($dom->createTextNode("deepsky" . $value['observationid'])); $attr = $dom->createAttribute("isPermaLink"); $guidDom->appendChild($attr); $attrText = $dom->createTextNode("false"); $attr->appendChild($attrText); $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate')); date_default_timezone_set('UTC'); $time = -999; $obs = $objObservation->getAllInfoDsObservation($value['observationid']); $time = $obs['time']; if ($time >= "0") { $hour = (int) ($time / 100); $minute = $time - 100 * $hour; } else { $hour = 0; $minute = 0; } $date = $value['observationdate']; $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $month, $day, $year)))); } 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"; global $instDir, $objCometObject; $objects = new CometObjects(); $observer = new Observers(); $instrument = new Instruments(); $observation = new CometObservations(); $location = new Locations(); $util = $this; $ICQMETHODS = new ICQMETHOD(); $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); $cometsResult = $observation->getObservationFromQuery($query); while (list($key, $value) = each($cometsResult)) { $objectname = $objCometObject->getName($observation->getObjectId($value)); // add root - <channel> - <item> $itemDom = $channelDom->appendChild($dom->createElement('item')); $title = htmlspecialchars_decode($objectname); // Location and instrument if ($observation->getLocationId($value) != 0 && $observation->getLocationId($value) != 1) { $title = $title . " from " . htmlspecialchars_decode($location->getLocationPropertyFromId($observation->getLocationId($value), 'name')); } if ($observation->getInstrumentId($value) != 0) { $title = $title . " with " . htmlspecialchars_decode($instrument->getInstrumentPropertyFromId($observation->getInstrumentId($value), 'name')); } $titleDom = $itemDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode($title)); $linkDom = $itemDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value)); // Description $description = $observation->getDescription($value); if (strcmp($description, "") != 0) { $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($description)))); } else { $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection("")); } $observerid = $observation->getObserverId($value); $observername = $observer->getObserverProperty($observerid, 'firstname') . " " . $observer->getObserverProperty($observerid, 'name'); $authorDom = $itemDom->appendChild($dom->createElement('dc:creator')); $authorDom->appendChild($dom->createCDATASection($observername)); $guidDom = $itemDom->appendChild($dom->createElement('guid')); $guidDom->appendChild($dom->createTextNode("comet" . $value)); $attr = $dom->createAttribute("isPermaLink"); $guidDom->appendChild($attr); $attrText = $dom->createTextNode("false"); $attr->appendChild($attrText); $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate')); date_default_timezone_set('UTC'); $date = sscanf($observation->getLocalDate($value), "%4d%2d%2d"); $time = $observation->getLocalTime($value); $hour = (int) ($time / 100); $minute = $time - $hour * 100; $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $date[1], $date[2], $date[0])))); } // generate xml $dom->formatOutput = true; // set the formatOutput attribute of // domDocument to true // save XML as string or file $test1 = $dom->saveXML(); // put string in test1 print $test1; }
public function actionFullupload() { /* $price_update = Prices::model()->findByAttributes(['trade_date'=>'0000-00-00', 'instrument_id' =>43], [ 'condition'=>'price!=:price', 'params'=>array('price'=>17.420), ] ); var_dump($price_update); exit; */ $model = new Uploads(); //$path = Yii::app()->basePath.'../../uploads/'; $path = Yii::getPathOfAlias('webroot') . '/uploads/'; if (isset($_POST['Uploads'])) { Yii::import('ext.phpexcel.XPHPExcel'); XPHPExcel::init(); ini_set('max_execution_time', 150000); ini_set("memory_limit", "128M"); require_once Yii::app()->basePath . '/extensions/XLSXReader/XLSXReader.php'; //OKarray(2) { ["Uploads"]=> array(2) { ["instrument_id"]=> string(2) "12" ["upload_description"]=> string(5) "sfggs" } ["yt0"]=> string(6) "Upload" } $model->attributes = $_POST['Uploads']; if ($upload_file = self::uploadMultifile($model, 'upload_file', $path)) { $model->upload_file = implode(",", $upload_file); } $model->user_id = Yii::app()->user->id; //$instrument_id = $model->instrument_id; ////////////////////////////////////////// if ($model->validate()) { //Upload File // if ($model->save()) { $upload_file_id = Yii::app()->db->getLastInsertID(); $csvFile = CUploadedFile::getInstance($model, 'upload_file', '../../uploads/'); $tempLoc = Yii::getPathOfAlias('webroot') . '/uploads/' . $model->upload_file; $xlsx = new XLSXReader($tempLoc); $data = $xlsx->getSheetData('Sheet1'); $instruments = Instruments::model()->findAll(array('select' => 'id, instrument')); $instruments_for_returns_update = []; foreach ($data as $dat) { $trade_date = gmdate('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($dat['0'])); $instrument_name = trim($dat['1']); $price = $dat['2']; $currency = $dat['3']; $instrument = Instruments::model()->findByAttributes(['instrument' => $instrument_name, 'is_current' => 1]); if ($instrument) { $instrument_id = $instrument->id; $instruments_for_returns_update[] = $instrument_id; } else { $new_instrument = new Instruments(); $new_instrument->instrument = $instrument_name; $new_instrument->price_uploaded = 1; $new_instrument->currency = $currency; $new_instrument->save(); $instrument_id = $new_instrument->id; $instruments_for_returns_update[] = $instrument_id; } $existing_record = Prices::model()->findByAttributes(['trade_date' => $trade_date, 'instrument_id' => $instrument_id]); if ($existing_record) { if ($existing_record->price !== $price) { $existing_record->price = $price; $existing_record->upload_file_id = $upload_file_id; $existing_record->save(); } } else { $new_price = new Prices(); $new_price->instrument_id = $instrument_id; $new_price->trade_date = $trade_date; $new_price->price = $price; $new_price->upload_file_id = $upload_file_id; //$new_price->name = $instrument_name; $new_price->save(); } } $unique_instruments_for_returns_update = array_unique($instruments_for_returns_update); Returns::model()->instrumnetReturnsUpdate($unique_instruments_for_returns_update); Yii::app()->user->setFlash('success', "Prices Uploaded!"); @chmod($tempLoc, 0777); @unlink($tempLoc); //unlink(Yii::getPathOfAlias('webroot').'/uploads/'.$model->upload_file); //$this->redirect(array('view','id'=>$model->id)); $user_data = Users::model()->findByPk(Yii::app()->user->id); $step_completed = $user_data->step_completed; if ($user_data->user_role == 2 && $step_completed < 2) { $user_data->step_completed = 1; $user_data->save(); $this->redirect(Yii::app()->baseUrl . '/site/admin'); } //else{ // $this->redirect(Yii::app()->baseUrl.'/site/admin'); // $this->render('overview', ['user_data' => $user_data]); } } } /////////////////////////////////////////// } $this->render('upload_form', array('model' => $model)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Instruments the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Instruments::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'prices-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => "{items}\n<div class=\"span\">{pager}</div><div class=\"span\">{summary}</div>", 'enablePagination' => true, 'type' => TbHtml::GRID_TYPE_BORDERED, 'pagerCssClass' => 'CustomPager', 'rowCssClass' => 'CustomPager', 'columns' => array('id', 'trade_date', array('name' => 'instrument_id', 'header' => 'Instrument', 'type' => 'raw', 'value' => function ($data) { $ss = Instruments::model()->findByAttributes(array("id" => $data->instrument_id)); if ($ss) { return $ss->instrument; } else { return '-'; } }, 'filter' => CHtml::listData(Instruments::model()->findAll(), 'id', 'instrument'), 'htmlOptions' => array('width' => '150px')), array('name' => 'price', 'header' => 'Price', 'type' => 'raw', 'value' => function ($data) { return number_format($data->price, 2); }, 'htmlOptions' => array('width' => '30px')), array('name' => 'is_current', 'header' => 'Is Current', 'type' => 'raw', 'value' => function ($data) { if ($data->is_current == 1) { return 'Yes'; } else { return 'No'; } }, 'filter' => CHtml::listData([['id' => 'Yes', 'instrument' => 'Yes'], ['id' => 'No', 'instrument' => 'No']], 'id', 'instrument'), 'htmlOptions' => array('width' => '30px')), 'created_at', array('class' => 'CButtonColumn', 'template' => $access_buttons)))); ?>
$where = ' 1 = 1 '; if (isset($_REQUEST['instrument']) && !($_REQUEST['instrument'] == '')) { $instrument_id = $_REQUEST['instrument']; } if (isset($_REQUEST['dt']) && !($_REQUEST['dt'] == '')) { $dt = $_REQUEST['dt']; $where .= " and l.trade_date >='{$dt}' "; } //$this->beginWidget('zii.widgets.CPortlet', array('title'=>"Selection",)); echo CHtml::beginForm('returnCalculation', 'post'); ?> <div class="row form-group"> <label class="col-md-3 control-label"></label> <div class="col-md-4"> <?php echo CHtml::dropDownList('instrument', $instrument_id, CHtml::listData(Instruments::model()->findAll(array('select' => 'id, instrument', 'order' => 'instrument')), 'id', 'instrument'), array('empty' => '-- Select Instrument --', 'class' => 'form-control')); ?> </div> </div> <div class="row form-group"> <label class="col-md-3 control-label"></label> <div class="col-md-4"> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'dt', 'options' => array('showAnim' => 'fold', 'dateFormat' => 'yy-mm-dd'), 'htmlOptions' => array('placeholder' => 'YYYY-MM-DD', 'class' => 'form-control'))); ?> </div> </div> <div class="row form-group"> <label class="col-md-3 control-label"></label>
if (empty($this->AllowedMethods)) { $this->AllowedMethods = ['GET']; } $requestDelegationCascade = $this->AutoHandleRequestDelegation; // Parent will validate CandID and Visit Label and abort if necessary parent::__construct($method, $CandID, $Visit); if ($requestDelegationCascade) { $this->handleRequest(); } } /** * Handles a GET request for this API call. * * @return none, but populates $this->JSON */ public function handleGET() { $Insts = $this->DB->pselect("SELECT DISTINCT Test_name" . " FROM flag f" . " JOIN session s ON (s.ID=f.SessionID)" . " WHERE s.CandID=:CID AND s.Active='Y' AND s.Visit_label=:VL", array('CID' => $this->CandID, 'VL' => $this->VisitLabel)); //array_column only exists in PHP 5.5+, need to use array_map //until we no longer support 5.4.. //$Instruments = array_column($Insts, 'Test_name'); $Instruments = array_map(function ($element) { return $element['Test_name']; }, $Insts); $this->JSON = ["Meta" => ["CandID" => $this->CandID, 'Visit' => $this->VisitLabel], 'Instruments' => $Instruments]; } } if (isset($_REQUEST['PrintInstruments'])) { $obj = new Instruments($_SERVER['REQUEST_METHOD'], $_REQUEST['CandID'], $_REQUEST['VisitLabel']); print $obj->toJSONString(); }
function selected_observation() { global $instDir, $baseURL, $dateformat, $step, $loggedUser, $objUtil, $objPresentations; // creation of objects $observations = new CometObservations(); $instruments = new Instruments(); $observers = new Observers(); $objects = new CometObjects(); $util = $objUtil; // selection of all observations of one object echo "<div id=\"main\">"; if (isset($_GET['objectname'])) { $queries = array("object" => $objects->getName($_GET['objectname'])); // sql query $sort = "id"; // standard sort on insertion date $obs = $observations->getObservationFromQuery($queries); if (sizeof($obs) > 0) { krsort($obs); } // save $obs as a session variable $_SESSION['obs'] = $obs; $_SESSION['observation_query'] = $obs; $count = 0; // counter for altering table colors $link = "" . $baseURL . "index.php?indexAction=comets_result_query_observations&objectname=" . $_GET['objectname']; echo "<h4>" . LangSelectedObservationsTitle . $objects->getName($_GET['objectname']) . "</h4>"; echo "<hr />"; if (sizeof($obs) > 0) { echo "<table class=\"table sort-tablecometobservations table-condensed table-striped table-hover tablesorter custom-popup\">\n\t <thead>\n\t\t <tr>\n\t <th>" . LangOverviewObservationsHeader1 . "</th>\n\t <th>" . LangOverviewObservationsHeader2 . "</th>\n\t <th>" . LangOverviewObservationsHeader4 . "</th>\n\t <th>" . LangNewComet1 . "</th>\n\t <th>" . LangViewObservationField3 . "</th>\n\t <th>" . LangViewObservationField19 . "</th>\n\t <th>" . LangViewObservationField18b . "</th>\n\t <th>" . LangViewObservationField20b . "</th>\n\t <th class=\"filter-false columnSelector-disable\" data-sorter=\"false\"></th>\n\t </tr>\n\t </thead>"; while (list($key, $value) = each($obs)) { // OBJECT $object = $observations->getObjectId($value); // overhead as this is every time the same object?! // OUTPUT echo "<tr>\n\t <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&object=" . urlencode($object) . "\">" . $objects->getName($object) . "</a></td>"; // OBSERVER $observer = $observations->getObserverId($value); echo "<td>"; echo "<a href=\"" . $baseURL . "index.php?indexAction=detail_observer&user="******"\">" . $observers->getObserverProperty($observer, 'firstname') . " " . $observers->getObserverProperty($observer, 'name') . "</a>"; echo "</td>"; // DATE if ($observers->getObserverProperty($loggedUser, 'UT')) { $date = sscanf($observations->getDate($value), "%4d%2d%2d"); } else { $date = sscanf($observations->getLocalDate($value), "%4d%2d%2d"); } echo "<td>"; echo date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0])); // TIME echo " ("; if ($observers->getObserverProperty($loggedUser, 'UT')) { $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d"); } else { $time = sscanf(sprintf("%04d", $observations->getLocalTime($value)), "%2d%2d"); } printf("%02d", $time[0]); echo ":"; printf("%02d", $time[1]); $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d"); echo ")</td>"; // INSTRUMENT $temp = $observations->getInstrumentId($value); $instrument = $instruments->getInstrumentPropertyFromId($temp, 'name'); $instrumentsize = $instruments->getInstrumentPropertyFromId($temp, 'diameter'); if ($instrument == "Naked eye") { $instrument = InstrumentsNakedEye; } // MAGNITUDE $mag = $observations->getMagnitude($value); if ($mag < -90) { $mag = ''; } else { $mag = sprintf("%01.1f", $observations->getMagnitude($value)); } // COMA $coma = $observations->getComa($value); if ($coma < -90) { $coma = ''; } else { $coma = $coma . "'"; } // DC $dc = $observations->getDc($value); if ($dc < -90) { $dc = ''; } // TAIL $tail = $observations->getTail($value); if ($tail < -90) { $tail = ''; } else { $tail = $tail . "'"; } if ($instrument != InstrumentsNakedEye && $instrument != "") { $instrument = $instrument . " (" . $instrumentsize . " mm" . ")"; } echo " <td>{$mag}</td>\n\t <td>{$instrument}</td>\n\t <td>{$coma}</td>\n\t <td>{$dc}</td>\n\t <td>{$tail}</td>"; // DETAILS echo "<td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value . "\">details"; // LINK TO DRAWING (IF AVAILABLE) echo "</a></td></tr>"; } echo "</table>"; $objUtil->addPager("cometobservations", sizeof($obs)); echo "<hr />"; echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "cometobservations.pdf.php\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage4a . "</a>"; echo "<br /><br />"; } else { echo LangNoObservations; } echo "</div>"; } elseif ($_GET['user']) { $query = array("observer" => $_GET['user']); $sort = "id"; // standard sort on date $obs = $observations->getObservationFromQuery($query, $sort); if (sizeof($obs) > 0) { krsort($obs); } // save $obs as a session variable $_SESSION['obs'] = $obs; $_SESSION['observation_query'] = $obs; $link = "" . $baseURL . "index.php?indexAction=comets_result_query_observations&user="******"<h4>" . LangSelectedObservationsTitle . $observers->getObserverProperty($_GET['user'], 'firstname') . " " . $observers->getObserverProperty($_GET['user'], 'name') . "</h4>"; echo "<hr />"; // NEW BEGIN if (sizeof($obs) > 0) { // OBJECT TABLE HEADERS echo "<table class=\"table sort-tablecometobservations table-condensed table-striped table-hover tablesorter custom-popup\">\n\t\t\t <thead>\n\t\t\t\t <tr>\n\t\t\t <th>" . LangOverviewObservationsHeader1 . "</th>\n\t\t\t <th>" . LangOverviewObservationsHeader4 . "</th>\n\t\t\t <th>" . LangNewComet1 . "</th>\n\t\t\t <th>" . LangViewObservationField3 . "</th>\n\t\t\t <th>" . LangViewObservationField19 . "</th>\n\t\t\t <th>" . LangViewObservationField18b . "</th>\n\t\t\t <th>" . LangViewObservationField20b . "</th>\n\t\t\t <th class=\"filter-false columnSelector-disable\" data-sorter=\"false\"></th>\n\t\t\t </thead>\n\t\t\t </tr>"; while (list($key, $value) = each($obs)) { // OBJECT $object = $observations->getObjectId($value); // OUTPUT echo "<tr>\n\t\t\t <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&object=" . urlencode($object) . "\">" . $objects->getName($object) . "</a></td>\n\t\t\t <td>"; // DATE if ($observers->getObserverProperty($loggedUser, 'UT')) { $date = sscanf($observations->getDate($value), "%4d%2d%2d"); } else { $date = sscanf($observations->getLocalDate($value), "%4d%2d%2d"); } echo date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0])); // TIME echo " ("; if ($observers->getObserverProperty($loggedUser, 'UT')) { $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d"); } else { $time = sscanf(sprintf("%04d", $observations->getLocalTime($value)), "%2d%2d"); } printf("%02d", $time[0]); echo ":"; printf("%02d", $time[1]); echo ")</td>"; // INSTRUMENT $temp = $observations->getInstrumentId($value); $instrument = $instruments->getInstrumentPropertyFromId($temp, 'name'); if ($instrument == "Naked eye") { $instrument = InstrumentsNakedEye; } // MAGNITUDE $mag = $observations->getMagnitude($value); if ($mag < -90) { $mag = ''; } // COMA $coma = $observations->getComa($value); if ($coma < -90) { $coma = ''; } else { $coma = $coma . "'"; } // DC $dc = $observations->getDc($value); if ($dc < -90) { $dc = ''; } // TAIL $tail = $observations->getTail($value); if ($tail < -90) { $tail = ''; } else { $tail = $tail . "'"; } echo " <td>{$mag}</td>\n\t\t\t <td>{$instrument}</td>\n\t\t\t <td>{$coma}</td>\n\t\t\t <td>{$dc}</td>\n\t\t\t <td>{$tail}</td>"; // DETAILS echo "<td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value . "\">details"; // LINK TO DRAWING (IF AVAILABLE) $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($value . "_resized.gif", $file) || fnmatch($value . "_resized.jpg", $file) || fnmatch($value . "_resized.png", $file)) { echo " + "; echo LangDrawing; } } echo "</a></td></tr>"; } echo "</table>"; $objUtil->addPager("cometobservations", sizeof($obs)); echo "<hr />"; $_SESSION['observation_query'] = $obs; echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "cometobservations.pdf.php\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage4a . "</a>"; } echo "<br /><br />"; echo "</div>"; } }
function selected_observations() { global $instDir, $baseURL, $loggedUser, $step, $dateformat, $objPresentations, $objUtil; $observations = new CometObservations(); $instruments = new Instruments(); $observers = new Observers(); $objects = new CometObjects(); $util = $objUtil; // TITLE echo "<div id=\"main\">"; $mindate = ''; $maxdate = ''; if ($_GET['observer'] || $_GET['instrument'] || $_GET['site'] || $_GET['minyear'] || $_GET['maxyear'] || $_GET['mindiameter'] && $_GET['mindiameterunits'] || $_GET['maxdiameter'] && $_GET['maxdiameterunits'] || $_GET['minmag'] || $_GET['maxmag'] || $_GET['description'] || $_GET['mindc'] || $_GET['maxdc'] || $_GET['mincoma'] || $_GET['maxcoma'] || $_GET['mintail'] || $_GET['maxtail'] || $_GET['object']) { if ($_GET['minyear'] && $_GET['minmonth'] && $_GET['minday']) { $mindate = $_GET['minyear'] . sprintf("%02d", $_GET['minmonth']) . sprintf("%02d", $_GET['minday']); } elseif ($_GET['minyear'] && $_GET['minmonth']) { $mindate = $_GET['minyear'] . sprintf("%02d", $_GET['minmonth']) . "00"; } elseif ($_GET['minyear']) { $mindate = $_GET['minyear'] . "0000"; } if ($_GET['maxyear'] && $_GET['maxmonth'] && $_GET['maxday']) { $maxdate = $_GET['maxyear'] . sprintf("%02d", $_GET['maxmonth']) . sprintf("%02d", $_GET['maxday']); } elseif ($_GET['maxyear'] && $_GET['maxmonth']) { $maxdate = $_GET['maxyear'] . sprintf("%02d", $_GET['maxmonth']) . "31"; } elseif ($_GET['maxyear']) { $maxdate = $_GET['maxyear'] . "1231"; } if ($_GET['mindiameter'] && $_GET['mindiameterunits'] == "inch") { $mindiam = $_GET['mindiameter'] * 25.4; } else { $mindiam = $_GET['mindiameter']; } if ($_GET['maxdiameter'] && $_GET['maxdiameterunits'] == "inch") { $maxdiam = $_GET['maxdiameter'] * 25.4; } else { $maxdiam = $_GET['maxdiameter']; } $maxmag = $_GET['maxmag']; $minmag = $_GET['minmag']; $description = $_GET['description']; $object = $_GET['object']; $mintail = $_GET['mintail']; $maxtail = $_GET['maxtail']; $mincoma = $_GET['mincoma']; $maxcoma = $_GET['maxcoma']; $mindc = $_GET['mindc']; $maxdc = $_GET['maxdc']; $observer = $_GET['observer']; if (array_key_exists('instrument', $_GET) && $_GET['instrument'] != "") { $instrument = $_GET['instrument']; $name = $instruments->getInstrumentPropertyFromId($instrument, 'name'); $instrument = $instruments->getId($name, $loggedUser); } else { $instrument = ''; } if (array_key_exists('site', $_GET) && $_GET['site'] != "") { $site = $_GET['site']; $name = $objLocation->getLocationPropertyFromId($site, 'name'); $site = $objLocation->getLocationId($name, $loggedUser); } else { $site = ''; } // QUERY $query = array("object" => $object, "observer" => $observer, "instrument" => $instrument, "location" => $site, "mindate" => $mindate, "maxdate" => $maxdate, "maxdiameter" => $maxdiam, "mindiameter" => $mindiam, "maxmag" => $maxmag, "minmag" => $minmag, "description" => $description, "mintail" => $mintail, "maxtail" => $maxtail, "mincoma" => $mincoma, "maxcoma" => $maxcoma, "mindc" => $mindc, "maxdc" => $maxdc); if (!$observers->getObserverProperty($loggedUser, 'UT')) { if ($mindate != "") { $mindate = $mindate - 1; } if ($maxdate != "") { $maxdate = $maxdate + 1; } } $sort = "date"; if (isset($catalogsearch)) { if ($catalogsearch == "yes") { $obs = $observations->getObservationFromQuery($query, $sort, 0); // LIKE } else { $obs = $observations->getObservationFromQuery($query, $sort); // EXACT MATCH } } else { $obs = $observations->getObservationFromQuery($query, $sort); // EXACT MATCH } // Dates can changes when we use local time! if (!$observers->getObserverProperty($loggedUser, 'UT')) { if ($mindate != "" || $maxdate != "") { if ($mindate != "") { $mindate = $mindate + 1; } if ($maxdate != "") { $maxdate = $maxdate - 1; } $newkey = 0; $new_obs = array(); while (list($key, $value) = each($obs)) { $newdate = $observations->getLocalDate($value); if ($mindate != "" && $maxdate != "") { if ($newdate >= $mindate && $newdate <= $maxdate) { $new_obs[$newkey] = $value; $newkey++; } } else { if ($maxdate != "") { if ($newdate <= $maxdate) { $new_obs[$newkey] = $value; $newkey++; } } else { if ($mindate != "") { if ($newdate >= $mindate) { $new_obs[$newkey] = $value; $newkey++; } } } } } $obs = $new_obs; } } if (sizeof($obs) > 0) { $link = $baseURL . "index.php?indexAction=comets_result_selected_observations" . "&object=" . urlencode($_GET['object']) . "&instrument=" . urlencode($_GET['instrument']) . "&observer=" . urlencode($_GET['observer']) . "&site=" . urlencode($_GET['site']) . "&minyear=" . $_GET['minyear'] . "&minmonth=" . $_GET['minmonth'] . "&minday=" . $_GET['minday'] . "&maxyear=" . $_GET['maxyear'] . "&maxmonth=" . $_GET['maxmonth'] . "&maxday=" . $_GET['maxday'] . "&maxdiameter=" . $_GET['maxdiameter'] . "&maxdiameterunits=" . urlencode($_GET['maxdiameterunits']) . "&mindiameter=" . $_GET['mindiameter'] . "&mindiameterunits=" . urlencode($_GET['mindiameterunits']) . "&maxmag=" . $_GET['maxmag'] . "&minmag=" . $_GET['minmag'] . "&description=" . $_GET['description'] . "&mindc=" . $_GET['mindc'] . "&maxdc=" . $_GET['maxdc'] . "&mincoma=" . $_GET['mincoma'] . "&maxcoma=" . $_GET['maxcoma'] . "&mintail=" . $_GET['mintail'] . "&maxtail=" . $_GET['maxtail']; echo "<h4>" . LangSelectedObservationsTitle2 . "</h4>"; echo "<hr />"; echo "<table class=\"table sort-tablecometobservations table-condensed table-striped table-hover tablesorter custom-popup\">"; echo "<thead><tr>"; // OBJECT NAME echo "<th>" . LangOverviewObservationsHeader1 . "</th>"; // OBSERVER echo "<th>" . LangOverviewObservationsHeader2 . "</th>"; // DATE echo "<th>" . LangOverviewObservationsHeader4 . "</th>"; // MAGNITUDE echo "<th>" . LangNewComet1 . "</th>"; // INSTRUMENT echo "<th>" . LangViewObservationField3 . "</th>"; // COMA echo "<th>" . LangViewObservationField19 . "</th>"; // DC echo "<th>" . LangViewObservationField18b . "</th>"; // TAIL echo "<th>" . LangViewObservationField20b . "</td>"; echo "<th class=\"filter-false columnSelector-disable\" data-sorter=\"false\"></th></tr></thead>"; $count = 0; while (list($key, $value) = each($obs)) { // OBJECT $object = $observations->getObjectId($value); // OBSERVER $observer = $observations->getObserverId($value); // INSTRUMENT $temp = $observations->getInstrumentId($value); $instrument = $instruments->getInstrumentPropertyFromId($temp, 'name'); $instrumentsize = $instruments->getInstrumentPropertyFromId($temp, 'diameter'); if ($instrument == "Naked eye") { $instrument = InstrumentsNakedEye; } // MAGNITUDE $mag = $observations->getMagnitude($value); if ($mag < -90) { $mag = ''; } else { $mag = sprintf("%2.01f", $mag); } // COMA $coma = $observations->getComa($value); if ($coma < -90) { $coma = ''; } else { $coma = $coma . "'"; } // DC $dc = $observations->getDc($value); if ($dc < -90) { $dc = ''; } // TAIL $tail = $observations->getTail($value); if ($tail > -90) { $tail = $tail . "'"; } else { $tail = ''; } // OUTPUT echo "<tr>\n\t <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_object&object=" . urlencode($object) . "\">" . $objects->getName($object) . "</a></td>\n\t <td><a href=\"" . $baseURL . "index.php?indexAction=detail_observer&user="******"\">" . $observers->getObserverProperty($observer, 'firstname') . " " . $observers->getObserverProperty($observer, 'name') . "</a></td>\n\t <td>"; if ($instrument != InstrumentsNakedEye && $instrument != "") { $instrument = $instrument . " (" . $instrumentsize . " mm" . ")"; } if (!$observers->getObserverProperty($loggedUser, 'UT')) { $date = sscanf($observations->getLocalDate($value), "%4d%2d%2d"); } else { $date = sscanf($observations->getDate($value), "%4d%2d%2d"); } echo date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0])); // TIME if (!$observers->getObserverProperty($loggedUser, 'UT')) { $time = sscanf(sprintf("%04d", $observations->getLocalTime($value)), "%2d%2d"); } else { $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d"); } echo " ("; printf("%02d", $time[0]); echo ":"; printf("%02d", $time[1]); $time = sscanf(sprintf("%04d", $observations->getTime($value)), "%2d%2d"); echo ")"; echo "</td>\n\t <td>{$mag}</td>\n\t <td>{$instrument}</td>\n\t <td>{$coma}</td>\n\t <td>{$dc}</td>\n\t <td>{$tail}</td>\n\t <td><a href=\"" . $baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value . "\">details"; // LINK TO DRAWING (IF AVAILABLE) $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($value . "_resized.gif", $file) || fnmatch($value . "_resized.jpg", $file) || fnmatch($value . "_resized.png", $file)) { echo " + "; echo LangDrawing; } } echo "</a></td></tr>"; $count++; } echo "</table>"; $objUtil->addPager("cometobservations", $count); echo "<hr />"; $_SESSION['observation_query'] = $obs; echo "<p><a class=\"btn btn-primary\" href=\"" . $baseURL . "cometobservations.pdf.php\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage4a . "</a>"; echo " <a class=\"btn btn-primary\" href=\"" . $baseURL . "cometobservations.icq\" rel=\"external\"><span class=\"glyphicon glyphicon-download\"></span> " . LangExecuteQueryObjectsMessage7 . "</a></p>"; } else { echo "<p>" . LangObservationNoResults . "</p>"; } echo "<p><a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_query_observations\">" . LangObservationQueryError2 . "</a></p>"; } else { echo "<p>" . LangObservationQueryError1 . "</p>"; echo "<p><a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_query_observations\">" . LangObservationQueryError2 . "</a>"; echo " " . LangObservationOR . " "; echo "<a class=\"btn btn-success\" href=\"" . $baseURL . "index.php?indexAction=comets_all_observations\">" . LangObservationQueryError3 . "</a></p>"; } echo "</div>"; }
$list = CHtml::listData($ports, 'id', 'portfolio'); echo CHtml::dropDownList('portfolio', $portfolio, $list, ['id' => 'portfolio', 'empty' => '-- Select --', 'onchange' => 'overviewload()', 'class' => "form-control"]); ?> </div> <div class="col-sm-2 control-label">Currency:</div> <div class="col-sm-2"> <?php echo CHtml::dropDownList('currency', 'USD', CHtml::listData(Currencies::model()->findAll(), 'currency', 'currency'), ['id' => 'currency', 'empty' => '-- Select --', 'onchange' => 'overviewload()', 'class' => "form-control"]); ?> </div> <div class="col-sm-2 control-label">Instrument:</div> <div class="col-sm-2"> <?php echo CHtml::dropDownList('instrument', '', CHtml::listData(Instruments::model()->findAll(), 'id', 'instrument'), ['id' => 'instrument', 'empty' => '-- Select --', 'onchange' => 'overviewload()', 'class' => "form-control"]); ?> </div> </div> </form> <div id="overview-view"></div> <div id="wait" style="display:none;width:69px;height:89px;position:absolute;top:50%;left:50%;padding:2px;"> <img src='<?php echo Yii::app()->theme->baseUrl; ?> /img/demo_wait.gif' width="64" height="64" /><br>Loading.. </div> <script>