public function init() { parent::init(); // Create new field in your users table for store dashboard preference // Set table name, user ID field name, user preference field name $this->setTableParams('dashboard_page', 'user_id', 'title'); // set array of portlets $this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4)))); //set content BEFORE dashboard $this->setContentBefore(); // uncomment the following to apply jQuery UI theme // from protected/components/assets/themes folder $this->applyTheme('ui-lightness'); // uncomment the following to change columns count //$this->setColumns(4); // uncomment the following to enable autosave $this->setAutosave(true); // uncomment the following to disable dashboard header $this->setShowHeaders(false); // uncomment the following to enable context menu and add needed items /* $this->menu = array( array('label' => 'Index', 'url' => array('index')), ); */ }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Net'])) { $model->attributes = $_POST['Net']; if ($model->save()) { $pointsAttached = $_POST['Net']['pointsattached']; $pointToNet = new PointToNet(); $pointToNet::model()->deleteAll('net_id = ' . $model->id); foreach ($pointsAttached as $attached) { $pointToNet->attributes = array('net_id' => $model->id, 'point_id' => $attached); $pointToNet->save(); $PointModel = Point::model()->findByPk($attached); $PointModel->CreateChannelsForWindows($model->screen_id, $attached); unset($PointModel); $pointToNet = new PointToNet(); } $model->CreateChannelsForWindows($model->screen_id, $model->id); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', 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 Point the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Point::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php /* @var $this PointController */ /* @var $model Point */ /* @var $form CActiveForm */ if (Yii::app()->controller->action->id == "create") { $id_point = $_GET['id']; } else { $id_point = $model->id_point; } $point = Point::model()->findByPk($id_point)->with('net'); $net = $point->net; $playlists = $net->playlists; $pls = array(); ?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'point-form', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <? echo $form->hiddenField($model,'id_point', array('value'=>$id_point)); ?>
/* @var $form CActiveForm */ ?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'point-form', 'enableAjaxValidation' => true)); ?> <p class="note"> Fields with <span class="required">*</span> are required. </p> <?php if (!$model->isNewRecord) { $netOwner = Point::model()->CheckNetOwnerExist($model->id); if ($netOwner != '') { printf('<p class="note"><span class="required">Attention! Point belongs to net %s any changes will throw it out.</span></p>', $netOwner['name']); } } ?> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'name'); ?>
echo $form->labelEx($model, 'WorkerID'); ?> <?php echo $form->dropDownList($model, 'WorkerID', CHtml::listData(Worker::model()->findAll(), 'ID', 'Fullname'), array('empty' => '-- Selecciona un operario --', 'style' => 'width: 200px;')); ?> <?php echo $form->error($model, 'WorkerID'); ?> </div> <div class="row" style="float: left;"> <?php echo $form->labelEx($model, 'PointID'); ?> <?php echo $form->dropDownList($model, 'PointID', CHtml::listData(Point::model()->findAll(), 'ID', 'Name'), array('empty' => '-- Selecciona el punto critico --', 'style' => 'width: 360px;')); ?> <?php echo $form->error($model, 'PointID'); ?> </div> <div class="clear"></div> <div class="row"> <?php echo $form->labelEx($model, 'Name'); ?> <?php echo $form->textField($model, 'Name', array('style' => 'width: 600px;', 'maxlength' => 150)); ?>
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $this->loadModel($id)->delete(); $this->DeleteTVBlocks($id); Point::model()->RemovePointSpoolPath($id); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { //$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); $model = new Point('search'); $model->unsetAttributes(); // clear any default values $this->redirect(array('point/index'), array('model' => $model)); } }
public function actionGetWidgets($id) { $point = Point::model()->findByPk($id); if (!isset($point)) { http_response_code(404); echo sprintf('Point with id %s does not exist.', $id); exit; } if (!$point->screen) { http_response_code(500); echo 'Point screen haven\'t been configured.'; exit; } $responce = ['responce_version' => '1']; $screen = $point->screen; $responce['screen'] = $screen->getInfo(); $channels = $point->channels; $responce['widgets'] = []; foreach ($channels as $channel) { $widgetToChannel = $channel->widgetToChannel; $window = $channel->window; if ($widgetToChannel && $window && $widgetToChannel->widget) { $widget = $widgetToChannel->widget; $widgetObj = $this->widget('application.widgets.' . ucfirst($widget->name) . 'Widget', ['type' => 'showData', 'config' => json_decode($widget->config)]); $responce['widgets'][] = ['window' => $window->getInfo(), 'config' => $widget->getInfo(), 'content' => $widgetObj->showData()]; } } echo json_encode($responce); exit; }