add card.flag implementation

This commit is contained in:
2016-03-09 20:16:19 +01:00
parent 1d3c476476
commit 42c326f407
25 changed files with 497 additions and 80 deletions

View File

@@ -9,6 +9,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use backend\models\InventoryItemForm;
use common\models\Inventory;
/**
* InventoryItemController implements the CRUD actions for InventoryItem model.
@@ -31,12 +32,19 @@ class InventoryItemController extends Controller
* Lists all InventoryItem models.
* @return mixed
*/
public function actionIndex()
public function actionIndex($id)
{
$searchModel = new InventoryItemSearch();
$inventory = Inventory::findOne($id);
if ( !isset($inventory)){
throw new NotFoundHttpException("Leltár nem található");
}
$searchModel = new InventoryItemSearch(['inventory' => $inventory]);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'model' => $inventory,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
@@ -68,7 +76,7 @@ class InventoryItemController extends Controller
$model->read();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_inventory_item]);
return $this->redirect(['inventory-item/index', 'id' => $model->inventory->id_inventory]);
} else {
return $this->render('create', [
'model' => $model,
@@ -103,9 +111,11 @@ class InventoryItemController extends Controller
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
$item = $this->findModel($id);
$id_inventory = $item->id_inventory;
$item->delete();
return $this->redirect(['index']);
return $this->redirect(['index', 'id' => $id_inventory]);
}
/**