public function testGetMonitorOptions() { $monitors = Monitor::model()->getMonitorOptions(); $this->assertTrue(3 === count($monitors)); $this->assertTrue(is_array($monitors)); $this->assertTrue(in_array('monitor1', $monitors)); $this->assertFalse(in_array('monitor4', $monitors)); }
public function actionSort() { $return = array('sukses' => false); if (isset($_POST['mon'])) { Monitor::model()->updateOrder($_POST['mon']); $return = array('sukses' => true); } $this->renderJSON($return); }
public function actionMonitorDetail($id, $serverId) { $namaTabel = "{$serverId}_{$id}"; $model = new MonitorDetail($namaTabel); $model->scenario = 'search'; $monitor = Monitor::model()->findByPk($id); $server = Server::model()->findByPk($serverId); $this->render('monitor_detail', ['model' => $model, 'server' => $server, 'monitor' => $monitor]); }
public function run() { $servers = ServerMonitor::model()->ambilServers($this->monitorId); $monitor = Monitor::model()->findByPk($this->monitorId); $tipeOutput = $monitor->outputType->nama; $tipeView = $monitor->viewType->nama; switch ($tipeView) { case 'linechart': $view = 'boxMonitorLineChart'; break; case 'onoffstatus': $view = 'boxMonitorOnOffStatus'; break; case 'text': $view = 'boxMonitorText'; break; } $this->render($view, array('title' => $this->title, 'monitorId' => $this->monitorId, 'servers' => $servers, 'tipeOutput' => $tipeOutput)); }
/** * 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 Monitor the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Monitor::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function updateOrder($listIds) { $order = 0; foreach ($listIds as $listId) { Monitor::model()->updateByPk($listId, array('order' => $order)); $order++; } }
?> <?php echo $form->dropDownListGroup($weather, 'code', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Weather::model()->getWeatherOptions(), 'htmlOptions' => array()))); ?> <?php echo $form->dropDownListGroup($theme, 'id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => $model->getThemeOptions(), 'htmlOptions' => array()))); ?> <?php echo $form->dropDownListGroup($commercial, 'id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Commercial::model()->getCommercialOptions(), 'htmlOptions' => array()))); ?> <?php echo $form->dropDownListGroup($model, 'monitor_id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Monitor::model()->getMonitorOptions(), 'htmlOptions' => array()))); ?> <?php echo $form->dropDownListGroup($model, 'dongle_id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Dongle::model()->getDongleOptions(), 'htmlOptions' => array()))); ?> <?php echo $form->dropDownListGroup($model, 'yeshuv_id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => Yeshuv::model()->getYeshuvOptions(), 'htmlOptions' => array()))); ?> <?php echo $form->textFieldGroup($model, 'url', array('wrapperHtmlOptions' => array('class' => 'col-sm-5', 'dir' => 'ltr'))); ?>
public function getMonitorOptions() { return CHtml::listData(Monitor::model()->findAll(array('order' => 'name')), 'id', 'name'); }
public function getNamaMonitor() { $monitor = Monitor::model()->findByPk($this->monitor_id); return $monitor->nama; }
public function actionLoadServer() { if (!empty($_POST['Notifikasi']['monitor_id']) || $_POST['Notifikasi']['monitor_id'] == '0') { $monitorId = $_POST['Notifikasi']['monitor_id']; if ($monitorId == 0) { /* Untuk uptime monitor, tampilkan semua server */ $servers = CHtml::listData(Server::model()->findAll(array('select' => 'id, nama', 'order' => 'nama')), 'id', 'nama'); foreach ($servers as $id => $nama) { echo CHtml::tag('option', array('value' => $id), CHtml::encode($nama), true); } } else { $monitor = Monitor::model()->findByPk($monitorId); $servers = $monitor->listServerAktif(); foreach ($servers as $server) { echo CHtml::tag('option', array('value' => $server['id']), CHtml::encode($server['nama']), true); } } } else { echo CHtml::tag('option', array('value' => ''), CHtml::encode('Pilih monitor..'), true); } }
public function getInfo() { /* Items allocated*/ $commodity['consumable'] = Consumable::model()->findAll(); $commodity['monitor'] = Monitor::model()->findAll(); $commodity['printers'] = Printers::model()->findAll(); $commodity['devices'] = Devices::model()->findAll(); $dup = $commodity; /* Items available on Loan*/ $availableOnLoan = 0; $thresholdItems = 0; $content = ''; foreach ($commodity as $key => $commo) { foreach ($commo as $item) { if ($item['available_on_loan'] == 1 || $item['available_on_loan'] == 'Yes') { ++$availableOnLoan; } if ($key == 'consumable') { $commodity = Commodity::model()->findByAttributes(array('name' => $key)); $allocates = Allocate::model()->findAllByAttributes(array('commodity_id' => $commodity['id'], 'cons_id' => $item['id'])); if (count($allocates) < $item['threshold']) { ++$thresholdItems; } } } } /** Allocated and unallocated **/ $countAllocated = 0; $countUnAllocated = 0; $commodity = $dup; $unAllocated = Allocate::model()->findAllByAttributes(array('date_out' => NULL)); $allocated = Allocate::model()->findAll('date_out IS NOT NULL'); $countAllocated += count($allocated); $countUnAllocated += count($unAllocated); $content .= '<b style="color:red">' . $availableOnLoan . '</b> item available on loan<br/>'; $content .= '<b style="color:red">' . $thresholdItems . '</b> item below threshold<br/>'; $content .= '<b style="color:red">' . $countAllocated . '</b> item allocated<br/>'; $content .= '<b style="color:red">' . $countUnAllocated . '</b> item unallocated<br/>'; /* Items below threshold*/ return $content; }
<div class="col-md-6"> <?php echo $form->textFieldGroup($migracion, 'disco_despues', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'))); ?> </div> <div class="col-md-6"> <?php echo $form->dropDownListGroup($migracion, 'cpu_id_despues', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => CHtml::listData(Cpu::model()->findAll(), 'id', 'procesador', 'marca'), 'htmlOptions' => array('prompt' => 'Seleccione Cpu')))); ?> </div> <div class="col-md-6"> <?php echo $form->dropDownListGroup($migracion, 'monitor_id_despues', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => CHtml::listData(Monitor::model()->findAll(), 'id', 'modelo', 'marca'), 'htmlOptions' => array('prompt' => 'Seleccione Monitor')))); ?> </div> </div> </div> </div> <?php } ?> <!-- FIN MIGRACION--> <?php } ?>
public function installMonitor() { $monitor = Monitor::model()->findByPk($this->monitor_id); $resultTableDef = $monitor->outputType->table_def; $transaction = $this->dbConnection->beginTransaction(); try { if ($this->save()) { Yii::app()->db->createCommand()->createTable($this->getResultTableName(), array('id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT', 'result' => $resultTableDef, 'waktu' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'keterangan' => 'varchar(512) DEFAULT NULL', 'PRIMARY KEY (`id`)'), 'ENGINE=MyISAM DEFAULT CHARSET=utf8'); $transaction->commit(); return true; } else { throw new Exception("Gagal Install Monitor"); } } catch (Exception $e) { $transaction->rollback(); throw $e; } }