public function actionEdit() { $this->layout = '//layouts/admin'; $success = false; $id = $_REQUEST['id']; $model = ListsFields::model()->findByPk($id); $list = Lists::model()->findByPk($model->list_id); $this->pageTitle = is_object($model) ? $model->name : 'Новая характеристика'; $this->breadcrumbs = array('Справочники' => array('/admin/lists'), $list->name => array('/admin/lists/edit/' . $list->id), 'Управление характеристиками' => array('/admin/lists/fields/list/' . $list->id), $model->title); if (isset($_POST['data']) && is_object($model)) { $dataArray = $_POST['data']; if ($dataArray['data_type'] == 'list' || $dataArray['data_type'] == 'multiple') { if (!isset($dataArray['rel']) || !$dataArray['rel']) { $newList = new Lists(); $newList->setAttributes(array("name" => "Справочник для <" . $dataArray['title'] . ">")); if ($newList->save()) { $dataArray['rel'] = $newList->id; } } } $model->setAttributes($dataArray); if ($model->save()) { $success = true; } } $this->render('edit', array('model' => $model, 'list' => $list, 'success' => $success, 'errors' => $model->errors)); }
public static function getListbyListID($idList) { $model = Lists::model()->findByPk($idList); return $model; }
?> ><?php echo $name; ?> </option> <?php } ?> </select> </div> <div class="form-group rel" style="display: none;"> <label>Связь</label> <select name="data[rel]" class="form-control"> <option value="">Выберите справочник</option> <?php $items = Lists::model()->findAll(); foreach ($items as $item) { ?> <option value="<?php echo $item->id; ?> "<?php echo $model->rel == $item->id ? ' selected="selected"' : ''; ?> ><?php echo $item->name; ?> </option> <?php } ?>
public function actionEdit() { $bookmark = Bookmarks::model()->findByPk(Yii::app()->request->getParam('bkid')); if ($bookmark === null) { $this->redirect(['index/index']); } if (Yii::app()->request->isPostRequest) { $bookmark->title = Yii::app()->request->getPost('bk_title'); $bookmark->url = Yii::app()->request->getPost('bk_url'); $bookmark->note = Yii::app()->request->getPost('bk_note'); $list = Lists::model()->findByPk(Yii::app()->request->getPost('bk_list')); if ($list !== null && $list->user_id == Yii::app()->user->id) { $bookmark->list_id = $list->id; } else { $bookmark->list_id = null; } $bookmark->save(); $this->redirect(['index/index']); } $lists = Yii::app()->user->model->lists; $this->render('edit', ['bookmark' => $bookmark, 'lists' => $lists]); }
if ($mobile) { echo CHtml::dropDownList('Place[sortField]', $sortFieldVal, $sorFieldList); } else { echo CHtml::radioButtonList('Place[sortField]', $sortFieldVal, $sorFieldList, array('class' => 'no-margin', 'separator' => ' ', 'labelOptions' => array('class' => 'radio-label right-margin'))); } ?> </div> </div> </div> <div class="row"> <div class="cell"> <label class="block-label">Show</label> <div class="input-wrapper"> <?php $radioButtonList = Lists::model()->getList("PublicPlacesParkType"); foreach ($radioButtonList as $thisKey => $radioButton) { if ($radioButton == 'None') { $radioButtonList[$thisKey] = 'All'; } } $typeId = isset($place['typeId']) ? $place['typeId'] : 1; ?> <?php if ($mobile) { echo CHtml::dropDownList('Place[typeId]', $typeId, $radioButtonList); } else { echo CHtml::radioButtonList('Place[typeId]', $typeId, $radioButtonList, array('class' => 'no-margin', 'separator' => ' ', 'labelOptions' => array('class' => 'radio-label right-margin'))); } ?> </div>
echo $form->textArea($model, 'description', ['style' => 'height:395px;width:750px;']); ?> </div> <?php echo $form->endControlGroup(); ?> <?php echo $form->beginControlGroup($model, 'status'); ?> <?php echo $form->controlLabel($model, 'status'); ?> <div class="controls"> <?php echo $form->radioButtonList($model, 'status', Lists::model()->getList("propertyCategoryStatus"), ['separator' => '']); ?> </div> <?php echo $form->endControlGroup(); ?> <?php echo $form->beginControlGroup($model, 'displayOnHome'); ?> <?php echo $form->controlLabel($model, 'displayOnHome'); ?> <div class="controls"> <?php echo $form->checkBox($model, 'displayOnHome');
<?php echo $form->labelEx($model, 'dateTo'); ?> <?php echo $form->textField($model, 'dateTo', array('placeholder' => 'dd/mm/yyyy', 'value' => $model->dateTo ? date("d/m/Y", strtotime($model->dateTo)) : "")); ?> <?php echo $form->textField($model, 'timeTo', array('placeholder' => 'hh:mm')); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', Lists::model()->getList("LocalEventStatus")); ?> </div> <h3>Events Address</h3> <?php $this->renderPartial("application.modules.admin4.views.location._location_form", array('model' => $address, 'form' => $form, 'parentModel' => $model, 'parentField' => 'addressID')); ?> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> </td> <td style="width:50%; vertical-align: top;">
echo $form->labelEx($model, 'longitude'); ?> <?php echo $form->textField($model, 'longitude'); ?> <?php echo $form->error($model, 'longitude'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'statusId'); ?> <?php echo $form->dropDownList($model, 'statusId', CHtml::listData(Lists::model()->findAllByAttributes(['ListName' => 'TransportStationsStatus'], ['order' => 'ListOrder DESC']), 'ListItemID', 'ListItem')); ?> <?php echo $form->error($model, 'statusId'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Save'); ?> <?php echo CHtml::button('Cancel', ['onclick' => 'window.parent.closeMarkerDetails();']); ?> </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 Lists the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Lists::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php echo $form->textField($model, 'bra_colour', ['class' => 'color']); ?> </div> <?php echo $form->endControlGroup(); ?> <?php echo $form->beginControlGroup($model, 'businessUnit'); ?> <?php echo $form->controlLabel($model, 'businessUnit'); ?> <div class="controls"> <?php echo $form->dropDownList($model, 'businessUnit', Lists::model()->getList('businessUnit')); ?> </div> <?php echo $form->endControlGroup(); ?> <?php echo $form->beginControlGroup($model, 'bra_status'); ?> <?php echo $form->controlLabel($model, 'bra_status'); ?> <div class="controls"> <?php echo $form->radioButtonList($model, 'bra_status', Branch::getStatuses(), ['separator' => '']);
<div class="control-group"> <label class="control-label">Status</label> <div class="controls"> <?php echo $form->checkBoxList($model, 'statusId', Lists::model()->getList("PublicPlacesStatus"), ['separator' => '']); ?> </div> </div> <div class="control-group"> <label class="control-label">Type</label> <div class="controls"> <?php echo $form->checkBoxList($model, 'typeId', Lists::model()->getList("PublicPlacesParkType"), ['separator' => '']); ?> </div> </div> </div> <div class="block-buttons force-margin"><?php echo $form->filterResetButton('Reset', ['class' => 'btn']); ?> </div> </fieldset> <?php $this->endWidget(); $buttonColumn = array('header' => 'Action', 'class' => 'CButtonColumn', 'template' => '{preview}{edit}{delete}', 'buttons' => array('preview' => array('label' => 'preview', 'url' => function ($data) { return $data->id; }, 'imageUrl' => Icon::PREVIEW_ICON, 'click' => "popUpPreview"), 'edit' => array('label' => 'Edit', 'url' => function ($data) {
<div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="panel-heading"> <a href="/admin/catalog" class="btn btn-success" title="Вернуться к списку товаров"><i class="fa fa-reply"></i> К списку товаров</a> <a href="/admin/catalog/fields/add" class="btn btn-success" title="Добавить характеристику"><i class="fa fa-plus"></i> Добавить характеристику</a> </div> <div class="panel-body"> <?php $types = array('' => '', 'varchar' => 'Строка', 'int' => 'Целое число', 'text' => 'Текст', 'html' => 'Html', 'date' => 'Дата', 'list' => 'Список', 'multiple' => 'Список с множественным выбором', 'bool' => 'Флаг'); $this->widget('CCustomGridView', array('id' => 'catalog-categories-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'cookey' => 'catalog-fields-size', 'columns' => array(array('name' => 'id', 'headerHtmlOptions' => array('style' => 'width: 100px')), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'category_id', 'value' => 'CatalogCategories::model()->findByPk($data->category_id)->name', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right', 'type' => 'select', 'source' => CHtml::listData(CatalogCategories::model()->findAll(), "id", "name")), 'filter' => CHtml::dropDownList("CatalogFilteredFields[category_id]", '', array_merge(array('' => ''), CHtml::listData(CatalogCategories::model()->findAll(), "id", "name")), array("class" => "form-control"))), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'name', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right'), 'filter' => CHtml::tag("input", array("name" => "CatalogFilteredFields[name]", "type" => "text", "class" => "form-control"))), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'title', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right'), 'filter' => CHtml::tag("input", array("name" => "CatalogFilteredFields[title]", "type" => "text", "class" => "form-control"))), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'data_type', 'value' => '$data->data_type', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'right', 'type' => 'select', 'source' => $types), 'filter' => CHtml::dropDownList("CatalogFilteredFields[data_type]", '', $types, array("class" => "form-control"))), array('class' => 'booster.widgets.TbEditableColumn', 'name' => 'rel', 'value' => '$data->rel ? Lists::model()->findByPk($data->rel)->name : "Не задано";', 'editable' => array('url' => $this->createUrl('eip'), 'placement' => 'top', 'type' => 'select', 'source' => CHtml::listData(Lists::model()->findAll(), "id", "name")), 'filter' => '', 'headerHtmlOptions' => array('style' => 'width: 120px')), array('class' => 'CCustomTogleColumn', 'toggleAction' => 'toggleFiltered', 'name' => 'in_filter', 'filter' => '', 'headerHtmlOptions' => array('style' => 'width: 130px')), array('header' => 'Действие', 'class' => 'CCustomButtonColumn')), 'pager' => array('class' => 'CCustomPager'))); ?> </div> </div> </div> </div>
public function actionEdit($id) { $this->layout = '//layouts/admin'; $success = false; $model = ListsItems::model()->findByPk($id); $list = Lists::model()->findByPk($model->list_id); $this->pageTitle = is_object($model) ? $model->name : 'Новый элемент справочника'; $this->breadcrumbs = array('Справочники' => array('/admin/lists'), $list->name => array('/admin/lists/edit/' . $list->id), is_object($model) ? $model->name : 'Новый элемент справочника'); if (isset($_POST['data']) && is_object($model)) { $dataArray = $_POST['data']; $additional = isset($dataArray['additional']) ? $dataArray['additional'] : array(); unset($dataArray['additional']); $model->setAttributes($dataArray); if ($model->save()) { $success = true; if (is_array($additional) && count($additional)) { foreach ($additional as $fieldName => $data) { $fieldModel = ListsFields::model()->findByAttributes(array("name" => $fieldName, "list_id" => $model->list_id)); if (is_object($fieldModel)) { switch ($fieldModel->data_type) { case 'varchar': case 'text': case 'html': $newVal = ListsFieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id)); if (!is_object($newVal)) { $newVal = new ListsFieldsValues(); } $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "text_val" => $data)); $newVal->save(); break; case 'int': case 'list': $newVal = ListsFieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id)); if (!is_object($newVal)) { $newVal = new ListsFieldsValues(); } $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $data)); $newVal->save(); break; case 'bool': $data = $data ? 1 : 0; $newVal = ListsFieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id)); if (!is_object($newVal)) { $newVal = new ListsFieldsValues(); } $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $data)); $newVal->save(); break; case 'date': $newVal = ListsFieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id)); if (!is_object($newVal)) { $newVal = new ListsFieldsValues(); } $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => strtotime($data))); $newVal->save(); break; case 'multiple': /* 09.04.2015 * TODO: придумать что то лучше, чем удаление записей перед созданием новых... */ $oldValues = ListsFieldsValues::model()->findAllByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id)); if (is_array($oldValues) && count($oldValues)) { foreach ($oldValues as $ov) { $ov->delete(); } } if (is_array($data) && count($data)) { foreach ($data as $v) { $newVal = new ListsFieldsValues(); $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $v)); $newVal->save(); } } break; } } } } if (isset($_FILES) && is_array($_FILES) && count($_FILES)) { foreach ($_FILES as $fieldName => $data) { $fieldModel = ListsFields::model()->findByAttributes(array("name" => $fieldName, "list_id" => $model->list_id)); $newVal = ListsFieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id)); if (!is_object($newVal)) { $newVal = new ListsFieldsValues(); } $uploaddir = 'images/upload/' . date("d.m.Y", time()); if (!is_dir($uploaddir)) { mkdir($uploaddir); } $tmp_name = $data["tmp_name"]; $name = $data["name"]; if ($name) { if ($newVal->text_val) { $pic = Yii::app()->basePath . "/.." . $newVal->text_val; if (is_file($pic)) { unlink($pic); } } $ext = explode(".", $name); $uploadfile = $uploaddir . '/nc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext); if (move_uploaded_file($tmp_name, $uploadfile)) { $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "text_val" => "/" . $uploadfile)); $newVal->save(); } } } } } } $this->render('edit', array('model' => $model, 'list' => $list, 'success' => $success, 'errors' => $model->errors)); }
echo $form->textArea($model, 'strapline', array('maxlength' => 200, 'rows' => 5, 'cols' => 46)); ?> </div> <?php echo $form->endControlGroup(); ?> <?php echo $form->beginControlGroup($model, 'statusId'); echo $form->controlLabel($model, 'statusId'); ?> <div class="controls"> <?php echo $form->radioButtonList($model, 'statusId', Lists::model()->getList("PublicPlacesStatus"), array('separator' => '')); ?> </div> <?php echo $form->endControlGroup(); ?> <?php echo $form->beginControlGroup($model, 'types'); echo $form->controlLabel($model, 'types'); ?> <div class="controls"> <?php echo $form->radioButtonList($model, 'typeId', Lists::model()->getList("PublicPlacesParkType"), array('separator' => '')); ?> </div> <?php echo $form->endControlGroup();
public function actionToggleActivity() { if (isset($_REQUEST['pk'])) { $model = Lists::model()->findByPk($_REQUEST['pk']); if (is_object($model)) { $model->is_active = $model->is_active ? 0 : 1; if ($model->save()) { return true; } } } return false; }