/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = StockGroup::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<!-- Fields with <span class="required">*</span> are required. --> <!--<p class="help-block"><?php echo Yii::t("Bootstrap", "PHRASE.FIELDS_REQUIRED"); ?> </p>--> <?php echo $form->errorSummary($model); ?> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 150)); ?> <?php echo $form->dropDownListRow($model, "group_id", CHtml::listData(StockGroup::model()->findAll(), "id", "name"), array('class' => 'span5', "empty" => "Нет группы")); ?> <?php echo '<label class="control-label required">Главные статьи</label> <div class="controls">' . $form->dropDownList($model, 'primary', array('0' => 'Нет', '1' => 'Да'), array('name' => 'Stock[primary]', 'title' => 'Главные статьи')) . '</div>'; ?> <?php Yii::import('ext.imperavi-redactor-widget-master.ImperaviRedactorWidget'); echo $form->label($model, 'brieftext'); $this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'brieftext', 'options' => array('lang' => 'ru', 'imageUpload' => Yii::app()->createAbsoluteUrl('/stock/stock/imageUpload')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js'))))); echo '<HR>'; echo $form->label($model, 'description'); $this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'description', 'options' => array('lang' => 'ru', 'imageUpload' => Yii::app()->createAbsoluteUrl('/stock/stock/imageUpload')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js')), 'myphotogalery' => array('js' => array('myphotogalery.js'))))); ?>
<legend><?php echo Yii::t("Bootstrap", "LIST.StockGroup"); ?> </legend> <?php $assetsDir = Yii::app()->basePath; $labels = StockGroup::model()->attributeLabels(); $this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'news-group-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) { return ' <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '"> <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div> </a> '; }, 'filter' => ''), array('header' => $labels["created_at"], 'name' => "created_at"), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{link}', 'buttons' => array('link' => array('label' => 'Список статей группы', 'options' => array('target' => '_blank'), 'url' => 'Yii::app()->createUrl("/stock/stock/index", array("Stock[group_id]"=>$data->id))')), 'htmlOptions' => array('style' => 'width: 80px')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap'))))); ?> <a href="/admin/<?php echo Yii::app()->controller->module->id; ?> /<?php echo Yii::app()->controller->id; ?> /create" class="btn">Добавить группу</a> <script> //Меняем статус $(document).on('click', '.on-off-product', function(){ $.ajax({ type: 'POST',
echo $form->errorSummary($model); ?> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 350)); ?> <?php Yii::import('ext.imperavi-redactor-widget-master.ImperaviRedactorWidget'); echo $form->labelEx($model, 'description'); $this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'description', 'options' => array('lang' => 'ru', 'cleanOnPaste' => false, 'cleanStyleOnEnter' => true, 'cleanSpaces' => false, 'replaceDivs' => false, 'imageUpload' => Yii::app()->createAbsoluteUrl('/pages/pages/imageUpload'), 'fileUpload' => Yii::app()->createAbsoluteUrl('/pages/pages/fileUpload'), 'imageManagerJson' => Yii::app()->createAbsoluteUrl('/pages/pages/getImageLibray')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js')), 'filemanager' => array('js' => array('filemanager.js')), 'myphotogalery' => array('js' => array('myphotogalery.js')), 'imagemanager' => array('js' => array('imagemanager.js'))))); ?> <?php echo $form->dropDownListRow($model, 'status', StockGroup::model()->getStatuslist(), array('class' => 'span5')); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'htmlOptions' => array('style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE'))); ?> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'link', 'label' => Yii::t('Bootstrap', 'PHRASE.BUTTON.RETURN'), 'url' => $this->listUrl('index'))); ?> </div>