Ejemplo n.º 1
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\date\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\BooksSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="books-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>

    <?php 
echo $form->field($model, 'author_id')->dropDownList(\app\models\Authors::getAuthorsName());
?>

    <?php 
echo $form->field($model, 'name');
?>


    <?php 
echo $form->field($model, 'date_start')->widget(DatePicker::classname(), ['language' => 'ru']);
?>

    <?php 
echo $form->field($model, 'date_end')->widget(DatePicker::classname(), ['language' => 'ru']);
?>
Ejemplo n.º 2
0
 public function actionAjax()
 {
     $request = Yii::$app->request;
     $post = $request->post();
     $returnArray = [];
     if ($model = $this->findModel($post['id'])) {
         $returnArray['author'] = \app\models\Authors::getAuthorsName($model->author_id);
         $returnArray['name'] = $model->name;
         $returnArray['preview'] = $model->preview;
         $returnArray['date_create'] = $model->date_create;
         $returnArray['date_update'] = $model->date_update;
         $returnArray['date'] = $model->date;
     }
     echo json_encode($returnArray);
     exit;
 }
Ejemplo n.º 3
0
        <?php 
echo Html::a('Новая запись', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
$label = new \app\models\Books();
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => '', 'columns' => ['id', 'name', ['label' => $label->getAttributeLabel('preview'), 'attribute' => 'preview', 'format' => 'raw', 'value' => function ($data) {
    $img_src = '/images/nophoto_100_100.jpg';
    if (!empty($data->preview) && file_exists('../web/' . $data->preview)) {
        $img_src = $data->preview;
    }
    return '
                    <a class="single_image" href="#"><img src="' . $img_src . '" style="width:100px;" alt=""/></a>';
}, 'filter' => ''], ['label' => $label->getAttributeLabel('author_id'), 'attribute' => 'author_id', 'format' => 'raw', 'value' => function ($data) {
    return \app\models\Authors::getAuthorsName($data->author_id);
}, 'filter' => ''], ['label' => $label->getAttributeLabel('date'), 'attribute' => 'date', 'format' => 'raw', 'value' => function ($data) {
    return \app\models\Books::returnDate($data->date);
}, 'filter' => ''], ['label' => $label->getAttributeLabel('date_create'), 'format' => 'raw', 'attribute' => 'date_create', 'value' => function ($data) {
    return \app\models\Books::returnDate($data->date_create);
}, 'filter' => ''], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Кнопки действий', 'template' => '{update} {view} {delete}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span data-id="' . $model->id . '" class="show_modal_books_edit glyphicon glyphicon-eye-open"></span>', $url, []);
}]]]]);
?>

</div>