public function actionDelete() { if (Blocks::model()->deleteByPk($_GET['id'])) { Yii::app()->user->setFlash('success', "Deleted!"); $this->redirect($this->createUrl("index")); } else { Yii::app()->user->setFlash('error', "Error!"); $this->redirect($this->createUrl("index")); } }
public static function menuSide() { $results = Terminals::model()->findAll(array('order' => 'name')); if ($results) { echo "<ul id='sideMenu' class='sample-menu'>"; foreach ($results as $model) { $block_name = $model->name; $results_block = Blocks::model()->findallByAttributes(array('terminals_id' => $model->id), array('order' => 'name')); //получаем массив с элементами относящиеся к терминалу с id_terminal $r = Yii::app()->getRequest()->getQuery('r'); if ($r == 'added/view') { $post_id = Yii::app()->getRequest()->getQuery('id'); } //Получаем id записи (при просмотре) $block_id = Yii::app()->request->getQuery('block_id'); //Получаем block_id (при фильтрации записей) $post = Added::model()->findByAttributes(array('id' => $post_id)); //строка записи id=post_id if ($results_block) { $ul_style = "<ul>"; foreach ($results_block as $model) { //цикл для проверки на совпадение if ($block_id == $model->id || $post->block_id == $model->id) { $ul_style = "<ul style='display: block;'>"; $a_name = "expanded"; } } } echo "<li><a href='#' class='rmenu' name='" . $a_name . "'><span></span>{$block_name}</a>"; $a_name = ""; if ($results_block) { echo $ul_style; foreach ($results_block as $model) { //цикл добавления пунктов меню echo "<li>"; if ($block_id == $model->id || $post->block_id == $model->id) { echo CHtml::link($model->name, array('/added', 'view' => 'index', 'block_id' => $model->id), array('style' => 'color: #73CE27; font-weight: bold')); } else { echo CHtml::link($model->name, array('/added', 'view' => 'index', 'block_id' => $model->id)); } echo "</li>"; } echo "</ul>"; } $a_style = ""; echo "</li>"; } echo "</ul>"; } }
echo $form->labelEx($model, 'date_memo', array('label' => 'Дата служебной записки')); ?> <?php echo CHtml::activeDateField($model, 'date_memo'); ?> <?php echo $form->error($model, 'date_memo'); ?> </div> </div> <div class="row block_id"> <?php echo $form->labelEx($model, 'block_id', array('label' => 'Печатная плата')); ?> <?php echo $form->dropDownList($model, 'block_id', CHtml::listData(Blocks::model()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => '(Выберите из списка)')); ?> <?php echo $form->error($model, 'block_id'); ?> </div> <div class="row"> <?php echo $form->textArea($model, 'note'); ?> <?php echo $form->error($model, 'note'); ?> </div> <?php echo $form->error($model, 'job');
<table class="table table-hover"> <thead> <tr> <th>Название</th> <th>Место</th> <td> </td> </tr> </thead> <tbody> <?php foreach ($pages as $item) { echo '<tr><td><a href="' . $this->createUrl("update", array("id" => $item->id)) . '">' . $item->name . '</a></td>'; echo "<td>" . Blocks::model()->getKeys()[$item->key] . "</td>"; echo '<td><a href="' . $this->createUrl("delete", array("id" => $item->id)) . '" onClick="return confirm(\'Are you sure you want to remove the item?\');">Удалить</a></td>'; echo '</tr>'; } ?> </tbody> </table> <?php } else { echo '<h3>Нет блоков</h3>'; } ?> </div>
/** * 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 Blocks the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Blocks::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }