public function actionAdmin() { $model = new Rental('search'); $model->unsetAttributes(); if (isset($_GET['Rental'])) { $model->setAttributes($_GET['Rental']); } $this->render('admin', array('model' => $model)); }
/** * @return \yii\db\ActiveQuery */ public function getRentals() { return $this->hasMany(Rental::className(), ['staff_id' => 'staff_id']); }
/** * @return \yii\db\ActiveQuery */ public function getRentals() { return $this->hasMany(Rental::className(), ['customer_id' => 'customer_id']); }
<?php $this->breadcrumbs[] = Yii::t('crud', 'Payments'); Yii::app()->clientScript->registerScript('search', "\n \$('.search-button').click(function(){\n \$('.search-form').toggle();\n return false;\n });\n \$('.search-form form').submit(function(){\n \$.fn.yiiGridView.update(\n 'payment-grid',\n {data: \$(this).serialize()}\n );\n return false;\n });\n "); ?> <?php $this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs)); ?> <h1> <?php echo Yii::t('crud', 'Payments'); ?> <small><?php echo Yii::t('crud', 'Manage'); ?> </small> </h1> <?php $this->renderPartial("_toolbar", array("model" => $model)); ?> <?php $this->widget('TbGridView', array('id' => 'payment-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{pager}{items}{pager}{summary}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('class' => 'CLinkColumn', 'header' => '', 'labelExpression' => '$data->itemLabel', 'urlExpression' => 'Yii::app()->controller->createUrl("view", array("payment_id" => $data["payment_id"]))'), array('class' => 'editable.EditableColumn', 'name' => 'payment_id', 'editable' => array('url' => $this->createUrl('/sakila/slim/payment/editableSaver'))), array('name' => 'customer_id', 'value' => 'CHtml::value($data,\'customer.itemLabel\')', 'filter' => CHtml::listData(Customer::model()->findAll(array('limit' => 1000)), 'customer_id', 'itemLabel')), array('name' => 'staff_id', 'value' => 'CHtml::value($data,\'staff.itemLabel\')', 'filter' => CHtml::listData(Staff::model()->findAll(array('limit' => 1000)), 'staff_id', 'itemLabel')), array('name' => 'rental_id', 'value' => 'CHtml::value($data,\'rental.itemLabel\')', 'filter' => CHtml::listData(Rental::model()->findAll(array('limit' => 1000)), 'rental_id', 'itemLabel')), array('class' => 'editable.EditableColumn', 'name' => 'amount', 'editable' => array('url' => $this->createUrl('/sakila/slim/payment/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'payment_date', 'editable' => array('url' => $this->createUrl('/sakila/slim/payment/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'last_update', 'editable' => array('url' => $this->createUrl('/sakila/slim/payment/editableSaver'))), array('class' => 'TbButtonColumn', 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("payment_id" => $data->payment_id))', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("update", array("payment_id" => $data->payment_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("payment_id" => $data->payment_id))'))));
echo $form->dropDownList($model, 'store_id', GxHtml::listDataEx(Store::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'store_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'last_update'); ?> <?php echo $form->textField($model, 'last_update'); ?> <?php echo $form->error($model, 'last_update'); ?> </div><!-- row --> <label><?php echo GxHtml::encode($model->getRelationLabel('rentals')); ?> </label> <?php echo $form->checkBoxList($model, 'rentals', GxHtml::encodeEx(GxHtml::listDataEx(Rental::model()->findAllAttributes(null, true)), false, true)); ?> <?php echo GxHtml::submitButton('Save'); $this->endWidget(); ?> </div><!-- form -->
public function loadModel($id) { $model = Rental::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('crud', 'The requested page does not exist.')); } return $model; }
/** * @return \yii\db\ActiveQuery */ public function getRental() { return $this->hasOne(Rental::className(), ['rental_id' => 'rental_id']); }
<div class="row"> <?php echo $form->label($model, 'staff_id'); ?> <?php echo $form->dropDownList($model, 'staff_id', GxHtml::listDataEx(Staff::model()->findAllAttributes(null, true)), array('prompt' => 'All')); ?> </div> <div class="row"> <?php echo $form->label($model, 'rental_id'); ?> <?php echo $form->dropDownList($model, 'rental_id', GxHtml::listDataEx(Rental::model()->findAllAttributes(null, true)), array('prompt' => 'All')); ?> </div> <div class="row"> <?php echo $form->label($model, 'amount'); ?> <?php echo $form->textField($model, 'amount', array('maxlength' => 5)); ?> </div> <div class="row"> <?php echo $form->label($model, 'payment_date');
/** * @return \yii\db\ActiveQuery */ public function getRentals() { return $this->hasMany(Rental::className(), ['inventory_id' => 'inventory_id']); }
<?php $this->breadcrumbs = array($model->label(2) => array('index'), 'Manage'); $this->menu = array(array('label' => 'List' . ' ' . $model->label(2), 'url' => array('index')), array('label' => 'Create' . ' ' . $model->label(), 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('payment-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo 'Manage' . ' ' . GxHtml::encode($model->label(2)); ?> </h1> <p> You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo GxHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'payment-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('payment_id', array('name' => 'customer_id', 'value' => 'GxHtml::valueEx($data->customer)', 'filter' => GxHtml::listDataEx(Customer::model()->findAllAttributes(null, true))), array('name' => 'staff_id', 'value' => 'GxHtml::valueEx($data->staff)', 'filter' => GxHtml::listDataEx(Staff::model()->findAllAttributes(null, true))), array('name' => 'rental_id', 'value' => 'GxHtml::valueEx($data->rental)', 'filter' => GxHtml::listDataEx(Rental::model()->findAllAttributes(null, true))), 'amount', 'payment_date', array('class' => 'CButtonColumn'))));
<?php $this->breadcrumbs = array(Rental::label(2), 'Index'); $this->menu = array(array('label' => 'Create' . ' ' . Rental::label(), 'url' => array('create')), array('label' => 'Manage' . ' ' . Rental::label(2), 'url' => array('admin'))); ?> <h1><?php echo GxHtml::encode(Rental::label(2)); ?> </h1> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
<h2> <?php echo Yii::t('crud', 'Payments'); ?> </h2> <div class="btn-group"> <?php $this->widget('bootstrap.widgets.TbButtonGroup', array('type' => '', 'buttons' => array())); ?> </div> <?php $relatedSearchModel = $model->getRelatedSearchModel('payments'); $this->widget('TbGridView', array('id' => '/sakila/hybrid/payment-grid', 'dataProvider' => $relatedSearchModel->search(), 'filter' => count($model->payments) > 1 ? $relatedSearchModel : null, 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array('payment_id', array('name' => 'staff_id', 'value' => 'CHtml::value($data,\'staff.itemLabel\')', 'filter' => CHtml::listData(Staff::model()->findAll(array('limit' => 1000)), 'staff_id', 'itemLabel')), array('name' => 'rental_id', 'value' => 'CHtml::value($data,\'rental.itemLabel\')', 'filter' => CHtml::listData(Rental::model()->findAll(array('limit' => 1000)), 'rental_id', 'itemLabel')), array('class' => 'editable.EditableColumn', 'name' => 'amount', 'editable' => array('url' => $this->createUrl('/sakila/hybrid/customer/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'payment_date', 'editable' => array('url' => $this->createUrl('/sakila/hybrid/customer/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'last_update', 'editable' => array('url' => $this->createUrl('/sakila/hybrid/customer/editableSaver'))), array('class' => 'TbButtonColumn', 'viewButtonUrl' => "Yii::app()->controller->createUrl('/sakila/hybrid/payment/view', array('payment_id' => \$data->payment_id))", 'updateButtonUrl' => "Yii::app()->controller->createUrl('/sakila/hybrid/payment/update', array('payment_id' => \$data->payment_id))", 'deleteButtonUrl' => "Yii::app()->controller->createUrl('/sakila/hybrid/payment/delete', array('payment_id' => \$data->payment_id))")))); ?> <h2> <?php echo Yii::t('crud', 'Rentals'); ?> </h2> <div class="btn-group"> <?php $this->widget('bootstrap.widgets.TbButtonGroup', array('type' => '', 'buttons' => array())); ?> </div>